简体   繁体   中英

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?

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

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

For more documentation, see git help remote .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM