1

I forked a remote repository A that I do not own and began to do changes on it. Let's call this fork B.

Then someone asked me to add some functionality to project A. However, I don't want to fork A again since the two forks would have the same name.

Is there a way to clone A in new branch of B?

Rodrigo
  • 2,462
  • 1
  • 14
  • 34
  • https://stackoverflow.com/questions/1628088/reset-local-repository-branch-to-be-just-like-remote-repository-head – Rodrigo Aug 26 '18 at 16:03

1 Answers1

2

You can add A as a new remote (e.g. "upstream"):

git remote add upstream git@github.com:originalauthor/repo.git

Then you can check out that remote branch and turn it into a branch:

git checkout upstream/master
git checkout -b upstream-master

And then make your new changes on a branch diverged from that.


Ideally, you'll want to periodically rebase your changes on that branch, after pulling it:

git checkout upstream-master
git pull upstream --rebase
L3viathan
  • 25,498
  • 2
  • 53
  • 71