less than 1 minute read

Intro

Imagine this situation: you work hard on a forked repo during days, making lot of changes. Finally, you submitted the code just to realize that, for some reason (failures on target repository pipeline, etc), forks are not the way to go in order to have your precious changes on the target repo and you are requested to please, move your change into a branch inside the target repo.

If that your case, the following steps could be helpful.

Steps

  1. Clone the main repo
git clone https://github.com/owner/repo.git
cd repo
  1. Add your fork as a remote repository
git remote add fork git@github.com:username/repo.git

Note that we added the ssh url here just for convenience.

  1. fetch the fork
git fetch fork
  1. create a new branch in the main repo
git checkout -b new-branch-name
  1. merge your fork changes into the newly created branch
git merge fork/your-branch
  1. push that branch into the remote repo
git push origin new-branch-name
  1. from there, you can open a PR in the target repo.

Tags:

Categories:

Updated: