Search code examples
githubgit-forkgit-workflow

How to remove Github Fork Workflow & point the same local clone on my system to main repository


I forked from main repository and cloned the forked repository on my system. I am not liking the the Github forked workflow and want to move back to normal Github Workflow.

I do not want to delete my forked repository from system and clone from Main Repository.

Is there any way to point my local setup(from forked repo) to Main repo(from which i initially forked) without cloning(fresh setup) from Main Repository?


Solution

  • Yes, simply replace your remote origin by your original main repo URL, using git remote:

    git remote set-url origin /url/main/repo
    git remote remove upstream
    git for-each-ref --format='%(refname:short)' 'refs/remotes/upstream/*' |
    

    xargs git branch -D

    Then you can git fetch/git push directly from/to that main repo, and no longer to your fork.
    That is provided that you own the main repo as well, and have the right to push back to it.

    Don't forget that you don't have to clone a repo to make pull requests: you can make pull requests between branches of your main repo directly (share repository model).