S has added complicated instructions about gerrit/origin.
We are dozens of people to not have any problem. I temporarily removed these confusing instructions, and would like opinion from Git and Gerrit experts.
Here the text:
Using a "gerrit" remote consistently
Before starting with git-review
you should double-check how git
refers to repositories.
When you clone a repository, by default git gives the remote repository the nickname origin
(unless you override this with -o gerrit as the sample commands on this page do), thus most git how-tos on the web use "origin".
But the git-review
tool prefers to use a remote called gerrit
.
If you're pulling code from gerrit.wikimedia.org then "origin" and "gerrit" are equivalent, yet if you fetch or pull from one but log/show/commit to the other you'll get different results!
Here's how to fix it:
- Double check the git remotes (nicknames) available
git remote -v
If it shows something like
origin ssh://username@gerrit.wikimedia.org:29418/mediawiki/core.git (fetch) origin ssh://username@gerrit.wikimedia.org:29418/mediawiki/core.git (push)
then follow these steps.
- Rename "origin" to "gerrit"
git remote rename origin gerrit
If you already try git-review
, the above won't work since you will
probably have "gerrit" remote already. So just remove origin:
git remote rm origin
- Change the tracking branch for "git pull"
In order for "git fetch" and "git pull" to show a helpful
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, i.e. core and extensions.
- Checking if everything is OK
After changes the configuration should look like:
git remote -v
gerrit ssh://username@gerrit.wikimedia.org:29418/mediawiki/core.git (fetch)
gerrit ssh://username@gerrit.wikimedia.org:29418/mediawiki/core.git (push)
git branch -vv
*master abad0ee [gerrit/master: behind 53] Some comment
Should we let this section removed or should I add it again?