4 ms·
The primer says "The git branch command lets you create a new branch of your project. It creates a new commit with a new pointer label pointing at it." which is
by sateesh 15y ago
The primer says
"The git branch command lets you create a new branch of your project. It creates a new commit with a new pointer label pointing at it."
which is not correct. When a new branch is created it just creates a new pointer to the commit which one branches off from, there is no new commit made automatically.
- getsat 15y agoThe best description of git branch that I've heard so far is: "git branch is File -> Save As for your current branch"
- bostonvaulter2 15y agoThat's a pretty good analogy, although you need to remember that a plain git branch is like a File -> Save As that doesn't keep the new name of subsequent File -> Save's
- enkrs 15y agoSo like "File->Save As Copy" from Photoshop. Makes sense.
- sateesh 15y agoOne need to be careful while using an analogy. Though at the outset it looks like it explains the branching behavior of 'git' it ain't so. Say I have opened a File and do a File->Save as on a directory mounted from an external storage (say mounted via NFS ). In such a case the file contents need to copied to that storage and there are two copies of the same content. But with 'git' branching that is not the case at all. When you create a branch you just create a new reference to a commit and you start from there, nothing more than that.