Git 如何设置执行以下操作的参照规范?

Git 如何设置执行以下操作的参照规范?,git,Git,这可以将我的“主”分支推送到远程分支“生产” 但是,如何保存远程位置,以便只需执行git push production master?我不想在本地设立生产分支机构。这是发展,直到我把它推上去。那我只想做 git merge production 在服务器上获取最新副本。如果需要 git push -u origin master:refs/heads/production 然后Git会记住上游分支(u代表“set upstream”)。我不认为你能在这里得到你想要的东西(“what you

这可以将我的“主”分支推送到远程分支“生产”

但是,如何保存远程位置,以便只需执行git push production master?我不想在本地设立生产分支机构。这是发展,直到我把它推上去。那我只想做

git merge production
在服务器上获取最新副本。

如果需要

git push -u origin master:refs/heads/production

然后Git会记住上游分支(u代表“set upstream”)。

我不认为你能在这里得到你想要的东西(“what you want”是Git push production master),但是你可以通过两个配置条目得到稍微简单一点的东西:

git config remote.production.url ssh://...
git config remote.production.push master:production
之后:

git push production
git pushprod
将推送到指定的URL(注意:您可以设置
remote.production.pushurl
,为
production
创建单独的URL,用于获取和推送,但此处可能不需要这样做)。由于远程后没有refspec,
git push
将参考
remote.production.push
设置一个。由于存在
remote.production.push
,因此它将使用它来代替任何配置的
branch.master.remote
branch.master.merge
(如果存在)或
remote.pushdefault
(如果不存在)

这里的缺点是,如果您不小心写入:

git push production master
然后,
gitpush
将看到您指定了一个refspec并忽略
remote.production.push
。指定的refspec相当于(完整、冗长的版本)
refs/heads/master:refs/heads/master


为了避免最后一个缺点,您可以简单地配置别名,例如:

git config alias.pushprod "push origin master:production"
之后:

git push production
git pushprod

是一种更简短的方式来“输入”已经运行的完整命令。

这是如何工作的<代码>分支主控设置,用于从源站跟踪远程分支生产。所有内容都是最新的设置存储在
.git/config
中。这不是我想要的。上面的代码段将主分支推送到源上的远程分支生产。我不想弄乱我的主分支。设置上游后,只需执行
git push
,而不是
git push origin master
。我不希望它成为我的主上游。它只是一台服务器。我只想让“分支”能被合理的东西推动。如果可能的话,我想知道问题的确切语法。