Reputation: 16242
git checkout -b some_branch master
Is that equivalent to the statements:
git checkout master
git branch some_branch
git checkout some_branch
If not, then what is the difference?
And in terms of merging:
git checkout master
git pull
git pull origin some_branch
Is that the same as:
git checkout some_branch
git pull
git checkout master
git pull
git merge some_branch
Upvotes: 2
Views: 102
Reputation: 14890
Q1. Yes
Q2. No
No, because your pull order is different and the remote can change between these two events.
No, because git pull
is equivalent to git pull origin
only if there is no branch.topic.remote
in the config, when you are on a topic branch.
No, because pull.rebase
, branch.topic.rebase
and branch.autosetuprebase
config entries can make pull
re-base instead of making it merge.
No, because some_branch
will be in a different state at the end of the two scenarios. It will be updated (fetched and merged from origin) in the second case - after git checkout some_branch && git pull
, but only fetched in the first case after git pull origin some_branch
.
Upvotes: 4
Reputation: 18928
To your first question about checking out: Yes they are equivalent. The only difference is the number of characters you type.
To your second question about merging: Same answer as above.
I've found that Git has two basic kinds of commands: Granular and Composite.
Granular commands are things like git branch foo
for creating a branch. Composite commands are just an easier, quicker way of typing multiple granular commands, like git checkout -b foo master
.
Of the source control systems I've used, Git requires the most typing until you get to know the command set, and take advantage of all the little short cuts they've built in.
Upvotes: -1