Rocky Inde Rocky Inde - 5 months ago 28
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

and push it to
so as to create a remote branch at

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

Now, I wish to merge that commit to
. 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

  1. git merge origin/mybranch

  2. git merge mybranch

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

kan kan

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).