0

In our setup we check changes into Gerrit and they don't make it into origin, which is where we check out from, until they get peer reviewed.

As I am new to the whole Git/Gerrit stuff, after I pushed my changes into Gerrit, I actually went to clean up some local branches and actually deleted the branch I pushed the change from. So now I no longer have a local copy of my changes but they are in Gerrit. They are not in Git as they have not been peer reviewed yet.

So I went to restore my local changes by checking a new branch out of Gerrit and not the Git origin. Our remote config looks as follows

>git remote -v
gerrit  ssh://myuser@domain:port/server (fetch)
gerrit  ssh://myuser@domain:port/server (push)
origin  ssh://myuser@domain:port/server.git (fetch)
origin  ssh://myuser@domain:port/server.git (push)

I tried

>git checkout -b gmaster gerrit/refs/heads/master
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'gerrit/refs/heads/master' which can not be resolved as commit?

How do I check out a branch out of Gerrit that will include my change which I accidentally wiped out locally?

4

1 回答 1

2

如果您使用的是 gerrit,您可能应该可以访问 Web 界面,去那里,您会看到您的更改。

如果你有 gitk,另一个选择是:

gitk --all `git reflog | cut -c1-7`

在那里搜索您已删除的分支,您可以使用哈希进行检查。

于 2013-09-04T14:42:03.530 回答