Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a new branch in my fork from the original repository?

Tags:

git

I forked a repo and the original repo has gotten a new branch after I forked it.

OriginalRepo
   |
   +-BranchA
   |
   +-newBranch


MyFork
   |
   +-BranchA

I want to get the branch newBranch into my fork, how can I do this?

like image 530
Paul Murphy Avatar asked Nov 02 '15 22:11

Paul Murphy


People also ask

How do I update my fork from the original repo?

Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.

How do I create a new branch in an existing repository?

The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.

Does forking create a new branch?

When merging a fork, git effectively has to diff both entire codebase against one another, as a fork represents two full copies of the codebase. Forking creates a full copy of your repository, whereas branching only adds a branch to your exiting tree.


1 Answers

git remote add OriginalRepo repository-URL
git fetch OriginalRepo
git checkout newBranch
git push origin newBranch
like image 107
levi Avatar answered Sep 19 '22 17:09

levi