2

When working with regular git and pushing to master you can easily know what you're about to push. Even better if you simply check for not pushed changes. When working with Gerrit on the other hand you want to see if your changes are present in your review/branch. Unfortunately running something like this gives no difference if you have changes or not.

git push --dry-run --verbose origin HEAD:refs/for/master

Produces

Pushing to scm:/some/repository
To scm:/some/repository
 * [new branch]      HEAD -> refs/for/master

While push itself is rejected by remote:

Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done    
To scm:/some/repository
 ! [remote rejected] HEAD -> refs/for/master (no new changes)
error: failed to push some refs to 'scm:/some/repository'

The only alternative I see for such case is something like using generated link on Gerrit to access to remote branch created for review but even this is too complex for my git knowledge.

So in overall, how can I check if my local changes were pushed to Gerrit? I have lots of subprojects synchronized with repo but in overall I use custom script just to track down what happens. Quite often I change multiple repositories at once through IDE and I don't even check which repository I'm editing. After that I run my script which can already show me unstaged, staged and modified repositories. The only thing that's missing is actually showing repositories in which I already committed changed but did not push them to review yet (or did not update review). Obviously diff origin/master..HEAD --quiet does not work as review has some custom generated branch. Is there a way to easily show if I have to push something?

4

0 回答 0