User:Stang/Gerrit
Init
editkoi@vm1:~$ git config --global user.name "Stang"
koi@vm1:~$ git config --global user.email stang@toolforge.org
koi@vm1:~$ git config --global gitreview.remote origin
koi@vm1:~$ git config --global gitreview.username stang
koi@vm1:~$ git clone ssh://stang@gerrit.wikimedia.org:29418/mediawiki/core.git mediawiki
koi@vm1:~$ git clone ssh://stang@gerrit.wikimedia.org:29418/mediawiki/extensions/<extension>.git
koi@vm1:~$ git clone ssh://stang@gerrit.wikimedia.org:29418/mediawiki/skins/<skin-name>.git
koi@vm1:~/tmp$ git review -s --verbose
koi@vm1:~/tmp$ git checkout master
New Changes
editkoi@vm1:~/tmp$ git pull
koi@vm1:~/tmp$ git branch -b T114514
koi@vm1:~/tmp$ git add -A
koi@vm1:~/tmp$ git commit
koi@vm1:~/tmp$ git review -R
Amend
edit- Easy for me to know my previous changes (recommended):
koi@vm1:~/tmp$ git review -d 114514
koi@vm1:~/tmp$ git reset --soft HEAD^
koi@vm1:~/tmp$ git add -A
koi@vm1:~/tmp$ git commit --reuse-message=HEAD@{1}
koi@vm1:~/tmp$ git review -R
- Should be the default operation:
koi@vm1:~/tmp$ git review -d 114514
koi@vm1:~/tmp$ git commit --all --amend
koi@vm1:~/tmp$ git review -R
- Show diff between specified patchset and latest patchset (uncommon):
- (Actually lots of fancy command could be found after clicking "Download" link)
koi@vm1:~/tmp$ git review -m 114514,3
Manually rebase
editkoi@vm1:~/tmp$ git review -d 114514
koi@vm1:~/tmp$ git fetch origin master
koi@vm1:~/tmp$ git rebase -i origin/master
koi@vm1:~/tmp$ git add -A
koi@vm1:~/tmp$ git rebase --continue
koi@vm1:~/tmp$ git review -R
Patch
editkoi@vm1:~/tmp$ git format-patch -1 HEAD
koi@vm1:~/tmp$ git am < file.patch
Cleanup
editkoi@vm1:~/tmp$ git branch | grep -v "master" | xargs git branch -D
If master is messed up
koi@vm1:~/tmp$ git fetch origin master
koi@vm1:~/tmp$ git reset --hard origin/master
SSH
editkoi@vm1:~$ ssh-keygen -t ed25519 -f gerrit -m pem -C "koi@koishi.io"
koi@vm1:~$ echo gerrit.pub
# Automate ssh-agent startup
[ -z "$SSH_AUTH_SOCK" ] && eval "$(ssh-agent -s)"
Host *
AddKeysToAgent yes
Host gerrit.wikimedia.org
HostName gerrit.wikimedia.org
User stang
Port 29418
PreferredAuthentications publickey
IdentityFile ~/.ssh/gerrit
IdentitiesOnly yes
koi@vm1:~$ ssh gerrit.wikimedia.org
koi@vm1:~$ echo "kill -9 \$SSH_AGENT_PID" >> ~/.bash_logout
koi@vm1:~/mw/mediawiki-config$ cat ~/.gitconfig
[user]
email = stang@toolforge.org
name = Stang
[gitreview]
remote = origin
username = stang
[alias]
del = ! git branch | grep -v "master" | xargs git branch -D