本文翻译自:Git - push current branch shortcut
Is there a shortcut to tell Git to push the current tracking branch to origin? 是否有快捷方式告诉Git将当前跟踪分支推送到原点?
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 例如,假设我正在使用分支feature/123-sandbox-tests
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
. git知道当前是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. 编辑 :从版本2.0开始,git的默认行为已更改为更直观的行为,这是我想要实现的。 See