Reputation: 3703
So I originally cloned a repo thinking I wouldn't make changes and eventually decided to fork my own copy for personal use (it's a dotfiles repo). If I want to continue changes from the fork, what's the cleanest way to copy local commits from the original clone over to the forked repo?
Looked around and couldn't find exactly what I want here.
Clarification:
I have two repos now on my computer, one that's a clone of the original repo, and another a fork from the same repo. I made changes to the clone, but am hoping to move these local commits over to the fork.
Upvotes: 10
Views: 5254
Reputation: 120
Let's say you have main Repo as R, Original clone as C and current Fork as F. You want to get changes from C into F, without disturbing R.
You can achieve this by setting a remote upstream and syncing your fork.
Step1. To set upstream refer: https://help.github.com/articles/configuring-a-remote-for-a-fork/ Sitting in the branch of F, you can set upstream(or name it anything else you want to) to C. run:
git checkout <branch of F>
git remote add upstream <repo URL for C>
git remote -v
Step2. Syncing your fork. Refer: https://help.github.com/articles/syncing-a-fork/ run:
git checkout <branch of F>
git fetch upstream
git merge upstream/<branch of C>
This should bring changes from C into F. Just make sure you ensure the right branches are mentioned in the git commands.
Upvotes: 3
Reputation: 124997
The usual way to do this would be with git pull
, just as you would when you want to merge any commits from another repo.
Upvotes: 7