有没有捷径可以告诉Git将当前跟踪分支推送到原点?
注意:我知道我可以更改default push behavior,但我正在寻找一种不更改默认行为的临时解决方案。
例如,假设我在分支feature/123-sandbox-tests
上,我将使用
git push origin feature/123-sandbox-tests
这太乏味了。我在找一条捷径,比如
git push origin current # <- example, not working
其中git知道current是feature/123-sandbox-tests
。
git:从2.0版本开始,的默认行为已经更改为更直观的行为,这正是我想要实现的。详情请参见This SO question。
编辑2:ceztko's answer是最好的答案,因为它允许推送当前分支,而不考虑设置。
发布于 2014-01-04 22:22:40
根据git push
文档:
git push origin HEAD
A handy way to push the current branch to the same name on the remote.
所以我认为你需要的是git push origin HEAD
。此外,如果您还没有推送到源,那么在本地分支中设置上游跟踪信息的git push -u origin HEAD
也很有用。
发布于 2015-06-08 18:11:19
您可以使用以下命令配置git以推送到当前分支
git config --global push.default current
那就这么做吧
git push
这将把代码推送到您当前的分支。
发布于 2015-05-28 14:31:41
您应该在Default behavior of "git push" without a branch specified中查看类似的问题
基本上,它解释了如何将默认行为设置为只执行git push
来推送当前分支。也许你需要的是:
git config --global push.default current
其他选项:
https://stackoverflow.com/questions/14031970
复制相似问题