I believe the answer provided by atlassian says to change the name of the remote branch when you see the Push dialog.
- Open the push dialog
- Click on the remote branch name under the "Remote Branch" column (mine is presently 'master')
- Type in the new remo branch name - which would be 'refs/for/master' for me
- Click OK.
This appears to have properly pushed the commits into Gerrit for me. The problem I have now is that the 'refs/for/master' value doesn't persist. Now to figure that out. I will update this post once I've figured that out. Hope this helps even tho it's late to the game.
Update: it turns out that you need to add a push entry under remote origin in the .git/config. You should do this via the git config command (tho i did edit the file manually i'm sure that's bad practice). the push line i wrote is:
push = refs/heads/*:refs/for/*
for clarity here is my remote origin entry in .git/config:
[remote "origin"]
url = ssh://gerrit-test.example.com:29418/mystuff.git
fetch = +refs/heads/*:refs/remotes/origin/*
push = refs/heads/*:refs/for/*
In SourceTree you can now push and it will push to gerrit instead of the final repo. ( you can now also just do git push without specifying anything else and it will push to gerrit ). Note that after a push, SourceTree will still show a number on the Push button that says you still have stuff to push. This is because it is still fetching from the master repo and the changes you've pushed into gerrit have not yet been merged into the master repo. Once your changes have been merged into the master repo the number on the Push button will disappear.
sourceTree配合gerrit
git push origin master
这是为什么呢?看过【Gerrit】Gerrit工作流程及使用手册这篇文章的就会知道,gerrit增加了codereview的流程。所以会依赖一个临时分支,我们提交代码需要提交到该临时分支。
所以,使用以下命令拉取代码:
git push origin HEAD:refs/for/mastergit config remote.origin.push refs/heads/*:refs/for/*
修改config文件,无效!
第二种是创建一个自定义操作,执行脚本,脚本去正确push。事实证明好用!
1 使用xcode创建一个shell脚本,内容如下
#!/bin/sh # push.sh # KeepRunning # # Created by 王涛 on 2018/4/27. # Copyright © 2018年 niujinfeng. All rights reserved. # 获取当前分支名 branch=`git symbolic-ref --short -q HEAD` # push review git push origin HEAD:refs/for/${branch}
2 在sourceTree创建一个自定义操作,配置如下,参数一栏是脚本所在路径,请替换正确路径


评论
发表评论