So, i am at my master branch working.

I issue :

git checkout -b branch1

This will create a new branch named branch1 and will make it identical to my current branch master.

Git does this "mirroring" only the first time that i run it?

Every subsequent call to git checkout will just fetch the data for the branch i checkout?

有帮助吗?

解决方案

Yes, you're correct.

When you create a new branch it is initially identical to the branch it was made from. However, once that branch has been created any calls to checkout work only against that branch. Other tools, such as merge are used to work with your new branch against any other branch.

其他提示

Git doesn't have to fetch the data when you checkout a new branch, it already has it and has to only change the view you see on disk. When you create a new branch, there's very little to do, since with or without the branch designation the data is there already. A branch is simply a pointer to that data; when the branch is modified its pointer is moved forward.

http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging is a good introduction to how it works.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top