我使用以下命令推送到远程分支:

git push origin sandbox

如果我说

git push origin

这是在我的其他分支中也推送更改,还是只更新我的当前分支?我有三个分支:master、production和sandbox。

git推送文档对此不是很清楚,所以我想永远澄清这一点。

下面的git push命令会准确更新哪些分支和远程?

git push 
git push origin

上面的原点是一个遥控器。

我知道gitpush[remote][branch]将只将该分支推送到远程。


当前回答

git 2.37.0中的新配置

运行以设置自动设置远程,而不是更改推送默认行为

git config --global --add --bool push.autoSetupRemote true

它与push配合得很好。默认为简单的上游

参考文献:答案推特文档犯罪

其他回答

您可以使用命令推送当前分支

git push origin HEAD

(取自此处)

我只是把它放在.gitconfig别名部分,喜欢它的工作方式:

pub = "!f() { git push -u ${1:-origin} `git symbolic-ref HEAD`; }; f"

将使用gitpub或另一个具有gitpub repo名称的repo将当前分支推送到源。美味的

git push origin将推送源位置具有匹配远程分支的本地分支上的所有更改

工作方式类似于git push<remote>,其中<remote’是当前分支的远程(或源,如果当前分支没有配置远程)。

从git push手册页的Examples部分

git 2.37.0中的新配置

运行以设置自动设置远程,而不是更改推送默认行为

git config --global --add --bool push.autoSetupRemote true

它与push配合得很好。默认为简单的上游

参考文献:答案推特文档犯罪

我只是将代码提交到一个分支并将其推送到github,如下所示:

git branch SimonLowMemoryExperiments
git checkout SimonLowMemoryExperiments
git add .
git commit -a -m "Lots of experimentation with identifying the memory problems"
git push origin SimonLowMemoryExperiments