Git - 推送当前分支快捷方式 [英] Git - push current branch shortcut
问题描述
有没有告诉Git推动当前追踪分支到达原点的捷径?
注意:我知道我可以更改默认推送行为,但我正在寻找不改变默认行为的临时解决方案。
例如,假设我位于分支 feature / 123-sandbox-tests
我将使用
git push origin feature / 123-sandbox-tests
这很乏味。我正在寻找一个快捷方式,例如
git push origin current
其中git知道当前是特性/ 123-sandbox-tests
。
编辑:从版本2.0开始,git的默认行为已更改为更直观的行为,这是我想达到的。查看这个SO问题了解详情。
编辑2 : ceztko的回答是最好的答案,因为它允许推送当前分支,而不管设置如何。
git push
文档:
git push origin HEAD
将当前分支推送到远程同名的简便方法。
所以我认为你需要的是 git push origin HEAD
。如果您还没有推送到原始地址,它也可以用于 git push -u origin HEAD
在本地分支中设置上游跟踪信息。
Is there a shortcut to tell Git to push the current tracking branch to origin?
Note: I know that I can change the default push behavior, but I am looking for an ad-hoc solution that does not change the default behavior.
For example, suppose I am on branch feature/123-sandbox-tests
I would be using
git push origin feature/123-sandbox-tests
which is tedious. I am looking for a shortcut, something like
git push origin current
where git knows that current is feature/123-sandbox-tests
.
Edit: Starting from version 2.0, git's default behavior has changed to a more intuitive behavior, which is what I wanted to achieve. See This SO question for details.
Edit 2: ceztko's answer is the best answer as it allows to push the current branch, regardless of the settings.
According to git push
documentation:
git push origin HEAD
A handy way to push the current branch to the same name on the remote.
So I think what you need is git push origin HEAD
. Also it can be useful git push -u origin HEAD
to set upstream tracking information in the local branch, if you haven't already pushed to the origin.
这篇关于Git - 推送当前分支快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!