简体   繁体   中英

How can I automatically get git to push a local branch to a different remote branch

I have a deploy branch which differs from my master in that it contains various server-only asset files that I don't want polluting my master in development but I would like pushed to master on my server. Currently I type in the following git command every time I want to push my code:

git push heroku deploy:master

How do I modify my .git/config file so that I could achieve the same with

git push heroku

You have to make deploy track heroku/master . This could be achieved with

git branch --set-upstream deploy heroku/master

See the documentation of git branch for more details on that.

Another alternative: after your first git push heroku deploy:master , you could throw away your deploy branch ( git checkout master && git branch -D deploy ) and then create deploy from heroku/master again:

git checkout -b deploy heroku/master

This will set up tracking automatically.

The topic of tracking is also discussed in the Git Book and on git ready .

Set your config so that you don't have to worry about it

git config --global push.default tracking

Now each time you push, it will set up the tracking for subsequent pushes.

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