Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: How to fetch from a remote branch and merge into local branch?

Tags:

git

github

I am forking from

  • github.com/mantisbt/mantisbt

which results in

  • github.com/MYACCOUNT/mantisbt

from where I clone it and checkout the branch (I am interested in) to my local machine.

My issue is that I would like to fetch the latest branch (master-1.2.x) from the remote repository (mantisbt/mantisbt) and merge it under the same branch the to my local repository.

Which would result in something like

  • git fetch remote-repo-branch
  • git merge remote-repo-branch/local-branch

How is this done?

UPDATE:

content is fetched with

  • git fetch upstream master-1.2.x

and merged to currently checked out branch with

  • git merge origin/master-1.2.x
like image 626
udo Avatar asked Oct 30 '25 23:10

udo


1 Answers

Github has an example of exactly this in their "fork a repo" help documentation.

git remote add upstream git://github.com/mantisbt/mantisbt 
// Assigns the original repo to a remote called "upstream"
git fetch upstream
like image 194
ptomli Avatar answered Nov 02 '25 12:11

ptomli