After fetching from remote using git fetch
, we need to use something like
git merge origin/master
I would like to know if this command also does git commit
at the same time? Is the order origin/master
important? Can I write master/original
?
Using git merge origin/master refers to the master branch on the server. git merge master refers to your local master branch. By using git pull you can merge them if they diverge.
The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch.
But one of the notations that developers find themselves typing most often is git pull origin master : it downloads new changes from the branch named master on the remote named origin and integrates them into your local HEAD branch.
Once you reach a milestone, code from the development branch is merged to master. It's assumed that master branch points to the stable version of the project.
git merge origin/master
can do one of two things (or error).
In the first case, it creates a new commit that has two parents: the current HEAD
, and the commit pointed to by the ref origin/master
(unless you're doing something funny, this is likely to be (the local pointer to) the branch named master
on a remote named origin
, though this is completely conventional).
In the second case, where there is no tree-level merge necessary, rather than creating a new commit, it updates the currently checked-out ref to point to the same commit as is pointed to by origin/master
. (This is called a fast-forward merge -- git can be directed to either always or never do this when you merge through command-line flags).
It does not call git commit
directly, which is a higher-level (porcelain in the git-parlance) command intended for users.
Calling git merge master/original
will try and resolve master/original
to a commit, which will almost certainly (again, unless you've done something deliberate) not be the same as origin/master
. If you happen to have a remote named master
that has a branch named original
, it will create a new commit which has that as the second parent.
You may find git help rev-parse
to be helpful in deciphering how git attempts to resolve ref names or other notations into commits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With