Reputation: 940
Suppose I'm in branch 'abc-test'
git pull origin master
Does this merges master branch with my current Branch('abc-test') or do I need to run more commands?
Upvotes: 2
Views: 15727
Reputation: 487
run git fetch
to fetch latest changes, then run git rebase master
to update your branch to the latest changes in master.
Now, to answer your question: yes, git pull origin master
does merge them.
However, what you probably want is to apply the commits from master to your branch and then reapply yours on top of them.
That's known as a rebase. The git-rebase manual (which you can access straight from the terminal with git rebase --help
is full of helpful diagrams to help you understand what the commit graph looks like.
This is one of them:
Assume the following history exists and the current branch is "topic":
A---B---C topic
/
D---E---F---G master
From this point, the result of the following command:
git rebase master
would be:
A'--B'--C' topic
/
D---E---F---G master
If you use git pull
, your graph is going to get really messed up really quickly. Especially if you start using it to update local branches with new commits from a remote repo, because then you'd be creating merge commits from a branch to itself, which is unnecessary and often misleading.
Most of these situations can be avoid by running git pull --rebase
or simply git pull -r
instead of git pull.
Tip: use git log --oneline --graph
as frequently as you can so you can get used to your repos' graph and what are the effects of each git command on it.
Note: Be careful when rebasing too deeply. Read the git-rebase manual.
Upvotes: 6
Reputation: 1905
git pull origin master
will pull changes from the origin remote, master branch and merge them to the local checked-out abc-test
branchgit commit -m"Your commit Message"
git push
Upvotes: 2