Git 跟踪推拉的不同分支?

Git track different branches for push and pull?

我有一个 Git 存储库,它由 Gerrit 管理,您不推送到 <branch>,而是推送到 refs/for/<branch>,然后推送到 奇迹发生。因此,我希望 git pullgit push 有不同的行为。特别是,我希望 git pull<branch> 拉取,但 git push 推到 refs/for/<branch>。是否可以在 Git 中进行设置?

(注意:这是 ,但答案很简单,"no, but here's how you can make Git force you to always specify the refspec so you'll never accidentally push to the wrong branch," 这不是我要找的答案)

我使用以下配置:

 git remote add review ssh://user@review.example.com:29418/repo
 git config remote.pushDefault review
 git config remote.review.fetch master:master
 git config remote.review.push master:refs/for/master

即添加名为 review 的远程,为所有分支设置默认推送远程 到 review,从远程分支 mastermaster 配置 fetch/pull, 为 master 配置推送到远程分支 refs/for/master.