为Visual Studio配置git以推送到magic gerrit分支

时间:2017-12-17 14:03:20

标签: git visual-studio visual-studio-2017 gerrit

我正在使用Visual Studio和Gerrit。我正在尝试设置我的git配置,以便默认推送到魔术Gerrit分支refs / for / master,并且pull将正常。我已将我的git配置更改为:

[remote "origin"]
    url = ...
    fetch = +refs/heads/*:refs/remotes/origin/*
    push = refs/heads/*:refs/for/*  

但推送仍然是refs/heads/master

还试图改变

[branch "master"]
    remote = origin
    merge = refs/for/master

但VS继续从配置中删除此部分。

正确的方法是什么?

注意我并没有尝试将gerrit集成到VS中,我只是想让VS推送到正确的分支。

1 个答案:

答案 0 :(得分:0)

我的解决方法:

  1. 安装"vscode-commandbar"扩展名
  2. 配置新的状态栏命令按钮以运行git命令:
{
    "skipTerminateQuickPick": true,
    "skipSwitchToOutput": false,
    "skipErrorMessage": true,
    "commands": [
        {
            "text": "$(repo-push) Gerrit Push",
            "tooltip": "Run command: \"git push origin HEAD:refs/for/master\"",
            "color": "yellow",
            "command": "git push origin HEAD:refs/for/master",
            "alignment": "left",
            "skipTerminateQuickPick": false,
            "priority": 0
        }
    ]
}
  1. 重新启动VScode并在必要时启用新按钮)

结果: Status bar with the new button