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 status查看缓存目录中文件状态 git commit -m "【项目:删除数组元素】【ones: 1】【改动:第一次上传】"添加注释信息 git remote add origin https://git.wpsit.cn/hubu-2023-cpp-tasks/wangjie_2.git远程连接 git push -u origin master上传 其他命令 git config --list 查看信息 git clonehttps://ur...
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...
# The first commit's message is: Change my name a bit # This is the 2nd commit message: Update README formatting and add blame # This is the 3rd commit message: Add cat-file When you save that, you have a single commit that introduces the changes of all three previous commits. ...
$ 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)更新某个引用 ...
现在对目录中的两个文件执行 git add ,然后执行 git commit -m "first commit" 完成第一次提交,此时执行 git log 查看提交记录如下: 执行find .git/objects -type f ,可以看到当前 .git/objects 中有如下 4 个 object: 这就是开始时 Git 存储内容的方式——一个对象对应一个 SHA-1 校验和。校验和的前...
first commit 1. 2. 3. 4. 5. 6. 可以看到,这个commit ojbect 指向一个 tree object,第二第三行是作者和提交者的信息,空一行后是提交信息。 下面我们修改我们的项目,模拟版本的变更: $ echoversion3 > file.txt $ gitupdate-index--addfile.txt ...
当执行提交操作(git commit)时,暂存区的目录树写到版本库(对象库)中,master 分支会做相应的更新。即 master 指向的目录树就是提交时暂存区的目录树。 当执行 “git reset HEAD” 命令时,暂存区的目录树会被重写,被 master 分支指向的目录树所替换,但是工作区不受影响。 当执行 “git rm –cached <file>”...
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...