Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does git merge origin/master do?

Tags:

git

git-merge

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?

like image 448
Adam Lee Avatar asked Jun 21 '12 01:06

Adam Lee


People also ask

What does git merge master mean?

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.

What does git origin master mean?

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.

What does git pull origin master do?

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.

What does merge to master mean?

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.


1 Answers

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.

like image 55
Matt Enright Avatar answered Oct 17 '22 08:10

Matt Enright