Git and Gerrit FAQ

From MediaWiki.org
Jump to: navigation, search

Here is a FAQ concerning how to use Git and Gerrit.

Git[edit]

Pulling[edit]

Should I use git pull origin master or git pull gerrit master?[edit]

Unless you're a git expert, they should be the same. The remote repository "gerrit" is the "origin" for the code of Wikimedia projects. Change directory to a repository and enter enter git remote -v to see what remotes uses.

As Gerrit/Tutorial#Configuring git-review says, you can put

[gerrit]
defaultremote = origin

in ~/.config/git-review/git-review.conf to ensure this.

There used to be instructions for eliminating any duplications, somewhere

-- SPage (WMF) (talk) 23:04, 26 March 2015 (UTC)

It says "Please, commit your changes or stash them before you can merge." What do I do?[edit]

To discard your changes (and anything you had in the stash):

git stash
git stash clear

Now you can proceed with your pull.

Committing[edit]

What's the difference between git commit --amend and git commit --amend -a?[edit]

The -a option automatically stages all tracked, modified files before the commit, letting you skip the git add step unless you need to start tracking new files. A tracked file is a file that was in your last commit.

Submitting for review[edit]

When should I use git review -R rather than just git review?[edit]

You use git review -R when you don't want your changes to be rebased, because you already used git pull --rebase origin master. To be more specific, when amending an existing change (adding changes to an existing patch set), you don't want to rebase against the master branch, as it causes the diffs to be cluttered.

Gerrit[edit]

Comments[edit]

How do I save inline code comments? I can only save them as drafts.[edit]

When I comment on code inline or reply to comments inline I cannot save it properly, just as a draft.

A: It's another of Gerrit's unintuitive parts. You have to click the "review" button back in the change overview page, and the draft inline comments will be attached to your "global" comment when you save it.

What should I put in the cover message when I publish comments?[edit]

A: ?

Miscellaneous[edit]

How do I watch changes?[edit]

A: You have to watch projects. See Gerrit/watched projects.

How do I link to Gerrit URLs from Wikimedia wikis using internal link syntax?[edit]

For example, for bugs I can use [[bugzilla:1234|bug 1234]] to produce bug 1234.

A: To link to revision 1234 use [[gerrit:1234|revision 1234]]: revision 1234.

See also[edit]