Using GIT
Detached HEAD after commit
Examine the history
- git log
- git log --graph
- git log -G
- git show
Referencing a commit
- dae86e1950b1277e545cee180551750029cfe735
- HEAD, @
- tag name, branch name
- @{u}, branch@{u}
- foo^ (HEAD^, dae86e^, tag^, @{u}^, ...)
- foo~2, foo~3, foo~10, ...
- :/regex, foo^{/regex}
Ranges
- rev
- rev1..rev2
- rev1...rev2
git gui
- git gui blame
- git gui citool
gitk
- compact graph, easy navigation
- search (comments and diffs!)
- non-blocking!
- gitk branch, gitk rev1..rev2
- gitk file
fetch
$ git branch -a
* 10.1
bb-10.1-monty
bb-10.1-rediscover
bb-10.1-serg
galera-review
remotes/origin/10.1
remotes/origin/10.1-explain-json
remotes/origin/bb-10.1-4ksectors
remotes/origin/bb-10.1-serg
remotes/origin/bb-fast-connect
remotes/origin/bb-set-statement
remotes/gsoc/selfTuningOptimizer
remotes/roles/10.1
pull
- fetch + merge
- git pull --rebase
- git pull --ff-only
- git config pull.ff only
- gitk remotes/origin/10.1...10.1
- gitk @{u}...
pull/push --overwrite
- bzr push --overwrite
- bzr pull --overwrite
mergetool
- for each unmerged file
- ask what to do (use this or that, edit, etc)
- mark the file as “merged”
Move changes to a new branch
clean history
- linear history: pull.ff=only, rebase
- separate changes: git add -p
- history cleanup: interactive rebase
git rebase --interactive HEAD~5
pick a1e3eaf fix a duplicate macro definition
pick de4cfab sort a non-deterministic test result
pick b4daf8e split an assert
pick 90f2ec5 bugfix: incorrect cast causing random memory write
pick ab440b0 update sysvars_server_embedded,32bit.rdiff
# Rebase fe0112e..ab440b0 onto fe0112e
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
Keep a backup
- simply create a new branch at your current HEAD
- git branch backup
Keep a backup
bisect
$ git bisect start
$ git bisect bad
$ git bisect good HEAD~12
Bisecting: 5 revisions left to test (roughly 3 steps)
[fe0112e2] MDEV-7424: InnoDB: Assertion failure in thread 139901753345792 in file buf0mtflu.cc line 439
$ make; cd mysql-test; ./mtr sometest
$ git bisect good
Bisecting: 2 revisions left to test (roughly 2 steps)
[de4cfabe] sort a non-deterministic test result
$
automating bisect
$ git bisect start
$ git bisect bad
$ git bisect good HEAD~12
Bisecting: 5 revisions left to test (roughly 3 steps)
[fe0112e2] MDEV-7424: InnoDB: Assertion failure in thread 139901753345792 in file buf0mtflu.cc line 439
$ git bisect run make-and-run-mtr --noreorder foo bar
$ cat make-and-run-mtr
#!/bin/sh -ex
make -j5 || exit 125
cd mysql-test && ./mtr "$@"
Multiple repositories
bzr style