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.
To pull down (i.e. copy) the changes merged into your fork, you can use the Terminal and the git pull command. To begin: On your local computer, navigate to your forked repo directory. Once you have changed directories to the forked repo directory, run the command git pull .
You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com. Source: GitHub Guides.
Sync from the UI Clicking on that you have the possibility to compare the changes made in the source repo with the ones made in your forked repo, and also to automatically fetch and merge them into your repo.
You can only fork a repo. However, you can get the end result of what you want by running single-line piped command after your clone your fork locally.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With