User:Dan-nl/Git and Gerrit/Troubleshooting
Appearance
Incorrect remote
[edit]When you clone a repository with git, it defaults to using a remote nickname of âoriginâ, however, git-review
works with a remote nickname of âgerritâ. If you cloned the repository without specifying the remote nickname, -o gerrit
, then it will be named âoriginâ and this will create problems when using the git-review
tool to interact with the wikimedia gerrit server. Below are instructions on how to correct this issue :
View the git remotes available
[edit]$ git remote -v
# yields something like the following:
origin ssh://<your-username>@gerrit.wikimedia.org:29418/mediawiki/<gerrit-project-name>.git (fetch)
origin ssh://<your-username>@gerrit.wikimedia.org:29418/mediawiki/<gerrit-project-name>.git (push)
- If you see an âoriginâ entry after entering the above command, then continue with the steps below.
Rename âoriginâ to âgerritâ
[edit]- If you only saw an entry for âoriginâ then use the following command, otherwise, continue with Remove the âoriginâ remote.
$ git remote rename origin gerrit
Remove the âoriginâ remote
[edit]- If you saw an entry for both âoriginâ and âgerritâ then use the following command.
$ git remote rm origin
Change the tracking branch for âgit pullâ
[edit]- In order for âgit fetchâ and âgit pullâ to show a helpful message such as the one below:
Your branch is behind 'gerrit/master' by 63 commits, and can be fast-forwarded.
- You need to tell your local branch (for example âmasterâ) to track âgerrit/masterâ instead of âorigin/masterâ
$ git branch --set-upstream master gerrit/master
- After this you don't need âoriginâ anymore and you can safely use shortcuts like "git pull" to update your working copy. Unfortunately you must perform these steps for every project checked out, e.g., core and extensions.
Make sure the remote is okay
[edit]- After changes the configuration should look like:
$ git remote -v
gerrit ssh://<your-username>@gerrit.wikimedia.org:29418/mediawiki/<gerrit-project-name>.git (fetch)
gerrit ssh://<your-username>@gerrit.wikimedia.org:29418/mediawiki/<gerrit-project-name>.git (push)
$ git branch -vv
*master abad0ee [gerrit/master: behind 53] Some comment