简体   繁体   中英

How to pull latest change from Gerrit repo

I have a problem with pulling last commit changes from Gerrit server. To push changes to the server I use git push origin HEAD:refs/for/master. So, I thought I can do similar for pull - git pull origin HEAD:refs/for/master, but it didn't work. In the meanwhile I found, that we need to use whole ssh address like eg. git pull "ssh://the/address/to/repo", but this solution didn't work either. I got an error: could't find remote ref HEAD The only way I can pull the latest version is to open, on Gerrit server, last commit and to take the whole address with commit number. It looks like this, git pull "ssh://the/repo/address/" refs/changes/34/1234/1 Is it possible to pull changes without knowing last change number?

On a Gerrit server, refs/for/ is a "magic" name-space.

Gerrit is a Java implementation of a Git server, but it's not Git . 1 It's a server implementation, and it does have a Git repository "behind" the server. But the server accepts git push requests and shuttles them off for special processing, instead of putting new commits into the repository the way Git would. Commits received for this special processing get a "change ID" assigned to them if they don't already have one: doing this assignment changes the commit to a different commit.

Once a commit (or series of commits) has a change ID assigned, then Gerrit puts those commits into a repository, under yet another name: neither your branch name, nor your refs/for/ branch name, but rather a name based on the change-ID (plus a revision of that change ID).

To retrieve such a commit from a Gerrit server, you'll need to know the assigned name and the mapping. That's your refs/changes/34/1234/1 string. If you don't know how Gerrit builds this string, and don't know what the change ID will be, you can't anticipate what it will be.

Hence:

Is it possible to pull changes without knowing last change number?

No.


1 Well, technically, to say whether it is or is not Git, we'd have to define "Git". For this particular answer's purpose, I'm defining "Git" as "software that implements the Git protocol and uses references exactly the way Git uses references". It's the second half of this "and" that Gerrit violates—on purpose and for good reason and useful effect, but nonetheless, it violates it, so it's not Git.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM