简体   繁体   English

我如何自动获取git将本地分支推送到其他远程分支

[英]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. 我有一个deploy分支,它与我的master分支不同,因为它包含各种服务器专用资产文件,我不想污染开发中的master,但是我希望将其推送到我的服务器上。 Currently I type in the following git command every time I want to push my code: 目前,我每次想推送代码时都输入以下git命令:

git push heroku deploy:master

How do I modify my .git/config file so that I could achieve the same with 如何修改.git / config文件,以便可以通过

git push heroku

You have to make deploy track heroku/master . 您必须使deploy跟踪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. 有关更多详细信息,请参见git branch的文档。

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 push heroku deploy:master ,您可以丢弃您的deploy分支( git checkout master && git branch -D deploy ),然后再次从heroku/master创建deploy

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 . Git Bookgit 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. 现在,每次您按下时,它将为后续的按下设置跟踪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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