Branches in a Nutshell
Branching means you diverge from the main line of development and continue to do work without messing with that main line
Git can change the way that you develop
- 每一次stage、commit背后,Git都做了些什么?
A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is
master. As you start making commits, you’re given amasterbranch that points to the last commit you made. Every time you commit, themasterbranch pointer moves forward automatically.
How does Git know what branch you’re currently on? It keeps a special pointer called HEAD
1.分支是什么?
Branching means you diverge from the main line of development and continue to do work without messing with that main line
2 揭秘每一次stage、commit背后故事
when you stage:
-
Staging the files computes a checksum for each one
-
stores that version of the file in the Git repository (Git refers to them as blobs),
-
adds that checksum to the staging area
when you create a commit
- stores blobs as a
tree object - create a
commit object - ``commit object
存储着对tree object`的引用以及此次提交的其他信息

3 Git中的branch
A branch in Git is simply a lightweight movable pointer to one of these commits.
如下面的testing分支
How does Git know what branch you’re currently on? It keeps a special pointer called
HEAD
HEAD指针指向当前所在分支,切换分支,就是将HEAD指针指向该分支

4 Git分支的基本操作
-
创建分支
git branch 分支名 -
删除分支
git branch -d 分支名 -
切换分支
git checkout 分支名 -
创建并切换分支
git checkout -b 分支名 -
查看各个分支log
git log --oneline --decorate --graph --allgit log默认是查看当期分支下的log
2083

被折叠的 条评论
为什么被折叠?



