3 ms·
What is the difference between doing: git checkout -b bugFix git commit git checkout master git commit git merge bugFix master And
by nodesocket 14y ago
What is the difference between doing:
git checkout -b bugFix
git commit
git checkout master
git commit
git merge bugFix master
And
git branch bugFix
git commit
git checkout master
git commit
git merge bugFix master
- jspiros 14y agoCreating a branch with git branch bugFix does not automatically check it out, so you'd have to follow it up with git checkout bugFix but if you do git checkout -b bugFix it will create the branch and then check it out all in one step.
- nodesocket 14y agoYup, makes sense. Thanks.
- xxbondsxx 14y agoYep! Exactly. The status of the current branch your on is designated by the asterisk (like in real git), but in retrospect I guess it could be a bit more clear...
- micampe 14y agogit checkout -b bugFix creates the branch and puts you on that branch, git branch bugFix creates the branch and leaves you where you are, so in your first example you are committing on the branch and then merging to master, in the second example you are always committing to master. try it in the website and you’ll see that in the second case bugFix never changes. the merge will say nothing needs to be done because bugFix already contains all changesets in master.