本文主要是介绍Difference between HEAD / Working Tree / Index in Git,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转载至http://stackoverflow.com/questions/3689838/difference-between-head-working-tree-index-in-git
A few other good references on those topics:
- My Git Workflow
I use the index as a checkpoint.
When I’m about to make a change that might go awry — when I want to explore some direction that I’m not sure if I can follow through on or even whether it’s a good idea, such as a conceptually demanding refactoring or changing a representation type — I checkpoint my work into the index.
If this is the first change I’ve made since my last commit, then I can use the local repository as a checkpoint, but often I’ve got one conceptual change that I’m implementing as a set of little steps.
I want to checkpoint after each step, but save the commit until I’ve gotten back to working, tested code.
- Why Git is better than X
- Git Is Your Friend not a Foe Vol. 3: Refs and Index
They are basically named references for Git commits. There are two major types of refs: tags and heads.
- Tags are fixed references that mark a specific point in history, for example v2.6.29.
- On the contrary, heads are always moved to reflect the current position of project development.
Now we know what is happening in the project.
But to know what is happening right here, right now there is a special reference called HEAD. It serves two major purposes:
- it tells Git which commit to take files from when you checkout, and
- it tells Git where to put new commits when you commit.
When you run
git checkout ref
it pointsHEAD
to the ref you’ve designated and extracts files from it. When you rungit commit
it creates a new commit object, which becomes a child of currentHEAD
. NormallyHEAD
points to one of the heads, so everything works out just fine.
这篇关于Difference between HEAD / Working Tree / Index in Git的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!