Git 的第一个提交源码仅有约1000行,但是已经实现了Git的基本设计原理,比如初始化仓库、提交代码、查看代码diff、读取提交信息等,Git 定义了三个区:工作区(workspace)、暂存区(index)、版本库(commit history),也实现了三类重要的 Git 对象:blob、tree、commit。本文将从源码上分析 Git 的第一个
bogon:test-git lakeslove$ git commit -m 'first commit' 此时master出现 bogon:test-git lakeslove$ cat .git/refs/heads/master 7f2c3e37a5e2e87dd3eaee210c7435a2edd6be1d 继续查看.git/objects/,发现多了2个文件,其中一个是head中指向的文件7f2c bogon:test-git lakeslove$ find .git/objects/.git...
$ git commit -m <file> #提交指定文件 $ git commit -m “commit message” #提交所有更新过的文件 $ git commit -amend #修改最后一次提交 $ git commit -C HEAD -a -amend #增补提交(不会产生新的提交历史纪录) 查看提交历史 $ git log #查看提交历史 $ git log -p <file> #查看指定文件的提交...
If, on the other hand, you want to change the actualcontentof your last commit, the process works basically the same way — first make the changes you think you forgot, stage those changes, and the subsequentgit commit --amendreplacesthat last commit with your new, improved commit. Y...
Check it out! You’ve got a command! Nice work! Let’s commit this. git statusreveals modifiedMakefile,builtin.h, andgit.cas well as untrackedbuiltin/psuh.candgit-psuh. First, let’s take care of the binary, which should be ignored. Open.gitignorein your editor, find/git-pull, an...
当执行提交操作(git commit)时,暂存区的目录树写到版本库(对象库)中,master 分支会做相应的更新。即 master 指向的目录树就是提交时暂存区的目录树。 当执行 “git reset HEAD” 命令时,暂存区的目录树会被重写,被 master 分支指向的目录树所替换,但是工作区不受影响。 当执行 “git rm –cached <file>”...
$ find.git/refs type-f.git/refs/heads/master.git/refs/remotes/origin/master $ git log--oneline master 21b61e0 Second commit 1b63b62 First commit $ more.git/refs/heads/master 21b61e04b11b0bb6e8aedd8d21132974a23630be (1)更新某个引用 ...
So far, if you've made a commit locally, you're the only one that can see it. To let others see your work and begin collaboration, you should "push" your changes usinggit push. If you're pushing from a branch for the first time that you've created locally, you may need to give...
git commit是将暂存文件 提交到本地仓库区。 git add:就像「浏览我的相簿时,对图片点收藏 动作」,等到了朋友圈,对整个收藏相册做发送。 「不先add,只有git commit」带来的问题是 每选完一张图片就要去发送一次,体验感很不友好。 git commit:前面的add就像是把「所有要寄出的文件」 都放在一个信封中了,commit...
On the commit-level, resetting is a way to move the tip of a branch to a different commit. This can be used to remove commits from the current branch. For example, the following command moves thehotfixbranch backwards by two commits. ...