Search code examples
gitgit-branchgit-pushgit-pull

Setting where a local git branch pulls AND pushes


I am working on my forked repo with 2 main branches:

  • master: pulls from main_project/master
  • bootstrap: pulls from collaborator/bootstrap
  • The second remote is a fork also contributing to the main project

I want the above branches to pull from the respective related repos; however, I want them to push to origin/<branch> (master or bootstrap). I know I can designate a push by git push <remote> <branch>, but I want it to be simpler, if possible.

As a follow-up, would tracking a branch help in anyway? I am not aware of tracking, although I did read about it via similar SO questions. How would branch tracking affect my situation?


Solution

  • You can set a different push url by using the --push argument to git remote set-url. E.g.:

    git remote set-url --push git@github.com:someuser/somerepo
    

    For more documentation, see git help remote.