5344
5432
1万
管理员
本站资源如失效,请点击反馈!
$ mkdir git-demo-project$ cd git-demo-project
$ git init
$ ls .gitbranches/configdescriptionHEADhooks/info/objects/refs/
$ touch test.txt
$ git hash-object -w test.txte69de29bb2d1d6434b8b29ae775ad8c2e48c5391
$ ls -R .git/objects.git/objects/e6:9de29bb2d1d6434b8b29ae775ad8c2e48c5391
$ cat .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
$ git cat-file -p e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
$ echo 'hello world' > test.txt
$ git hash-object -w test.txt3b18e512dba79e4c8300dd08aeb37f8e728b8dad
$ git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dadhello world
$ git update-index --add --cacheinfo 100644 \3b18e512dba79e4c8300dd08aeb37f8e728b8dad test.txt
$ git ls-files --stage100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 test.txt
$ git status要提交的变更: 新文件: test.txt
$ git add --all
$ git config user.name "用户名" $ git config user.email "Email 地址"
$ git write-treec3b8bb102afeca86037d5b5dd89ceeb0090eae9d
$ git cat-file -p c3b8bb102afeca86037d5b5dd89ceeb0090eae9d100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad test.txt
$ echo "first commit" | git commit-tree c3b8bb102afeca86037d5b5dd89ceeb0090eae9dc9053865e9dff393fd2f7a92a18f9bd7f2caa7fa
$ git cat-file -p c9053865e9dff393fd2f7a92a18f9bd7f2caa7fatree c3b8bb102afeca86037d5b5dd89ceeb0090eae9dauthor ruanyf 1538889134 +0800committer ruanyf 1538889134 +0800first commit
$ git log --stat c9053865e9dff393fd2f7a92a18f9bd7f2caa7facommit c9053865e9dff393fd2f7a92a18f9bd7f2caa7faAuthor: ruanyf Date: Sun Oct 7 13:12:14 2018 +0800 first commit test.txt | 1 + 1 file changed, 1 insertion(+)
$ git commit -m "first commit"
$ git checkout c9053865e9dff393fd2f7a92a18f9bd7f2caa7fa
$ git show c9053865e9dff393fd2f7a92a18f9bd7f2caa7fa
$ git log
$ echo "hello world again" > test.txt
$ git hash-object -w test.txtc90c5155ccd6661aed956510f5bd57828eec9ddb
$ git update-index test.txt$ git write-tree1552fd52bc14497c11313aa91547255c95728f37
$ echo "second commit" | git commit-tree 1552fd52bc14497c11313aa91547255c95728f37 -p c9053865e9dff393fd2f7a92a18f9bd7f2caa7fa785f188674ef3c6ddc5b516307884e1d551f53ca
$ echo 785f188674ef3c6ddc5b516307884e1d551f53ca > .git/refs/heads/master
$ git logcommit 785f188674ef3c6ddc5b516307884e1d551f53ca (HEAD -> master)Author: ruanyf Date: Sun Oct 7 13:38:00 2018 +0800 second commitcommit c9053865e9dff393fd2f7a92a18f9bd7f2caa7faAuthor: ruanyf Date: Sun Oct 7 13:12:14 2018 +0800 first commit
查找HEAD指针对应的分支,本例是master 找到master指针指向的快照,本例是785f188674ef3c6ddc5b516307884e1d551f53ca 找到父节点(前一个快照)c9053865e9dff393fd2f7a92a18f9bd7f2caa7fa 以此类推,显示当前分支的所有快照
git commit:当前分支指针移向新创建的快照。 git pull:当前分支与远程分支合并后,指针指向新创建的快照。 git reset [commit_sha]:当前分支指针重置为指定快照。
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
手机版|飞雪团队
GMT+8, 2024-11-24 01:04 , Processed in 0.065519 second(s), 21 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.