Rocky Inde Rocky Inde - 3 months ago 12
Git Question

Is merging from remote branch or local branch technically the same?

Let me explain the question with an example.

Let us say, I create a new branch from my

master
and push it to
origin
so as to create a remote branch at
origin/mybranch
.

Next I make changes in this branch, stage, commit & push.

Now, I wish to merge that commit to
master
. For simplicity, let us assume there are no other changes/commits in any of the branches apart from the one that I specified.

My question is: would the following two commands lead to the exact same state (in my local
master
branch):


  1. git merge origin/mybranch

  2. git merge mybranch



I didn't know how else to phrase this question.

kan kan
Answer

A branch in git is just a human-friendly symbolic name of a commit. So, if branches point to the same commit - the result of merge will be identical. You could also could do git merge <commit_id>.

The only noticeable difference is a default message text of the merge commit if any (and you could edit it if you want).