I have a repo called at MAIN/repo.git
and I've forked it to FORK/repo.git
. I have both of these repos cloned onto my computer for different purposes.
Using Github for Windows, a bug seems to have switched FORK/repo.git
over to MAIN/repo.git
, as when I do git remote show origin
, the Fetch URL and Push URL are set to the main repo. How can I switch this back so the corresponding folder on my local machine points to FORK/repo.git
, instead of MAIN/repo.git
?
To sync your forked repo with the parent or central repo on GitHub you: Create a pull request on GitHub.com to update your fork of the repository from the original repository, and. Run the git pull command in the terminal to update your local clone.
Previously, when you forked a repository the fork name would default to the same name as the parent repository. In some cases, that wasn't ideal because you wanted the fork to have a different name. Your only option was to rename the fork after it was created.
Access your forked repository on Github. Click “Pull Requests” on the right, then click the “New Pull Request” button. Github first compares the base fork with yours, and will find nothing if you made no changes, so, click “switching the base”, which will change your fork to the base, and the original to the head fork.
The easiest way would be using command-line git remote
, from within your local clone of FORK
:
git remote rm origin git remote add origin https://github.com/user/FORK.git
Or, in one command, as illustrated in this GitHub article:
git remote set-url origin https://github.com/user/FORK.git
A better practice is to:
So:
git remote rename origin upstream git branch -avv # existing branches like master are linked to upstream/xxx git remote add origin https://github.com/user/FORK.git git checkout -b newFeatureBranch
Whenever you need to update your fork based on the recent evolution of the original repo:
git checkout master git pull # it pulls from upstream! git checkout newFeatureBranch git rebase master # safe if you are alone working on that branch git push --force # ditto. It pushes to origin, which is your fork.
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