User:Dan-nl/Git and Gerrit/Troubleshooting

From mediawiki.org

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