My git cheatsheet

Show git log as tree

$ git log --oneline --graph --decorate --all
| * 0255f78c (HEAD -> qmtech, my/qmtech) added support for qm_xc6slx16_sdram board
| * dae037cf (my/spisingle, spisingle) added spi 1-bit mode, code from litex
|/
* 1325aff6 (origin/master, origin/HEAD, master) correctly use result of Record.connect in Converter (#81)

Rebasing

git rebase --onto <where-to> <where-from> <what>
$ git rebase --onto master spisingle qmtech
First, rewinding head to replay your work on top of it...
Applying: added support for qm_xc6slx16_sdram board

$ git log --oneline --graph --decorate --all
* 37d2eff0 (HEAD -> qmtech) added support for qm_xc6slx16_sdram board
| * 0255f78c (my/qmtech) added support for qm_xc6slx16_sdram board
| * dae037cf (my/spisingle, spisingle) added spi 1-bit mode, code from litex
|/
* 1325aff6 (origin/master, origin/HEAD, master) correctly use result of Record.connect in Converter (#81)

Push changed branch

$ git push my qmtech -f
Counting objects: 7, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.86 KiB | 1.86 MiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https://github.com/danielkucera/misoc.git
+ 0255f78c...37d2eff0 qmtech -> qmtech (forced update)

$ git log --oneline --graph --decorate --all
* 37d2eff0 (HEAD -> qmtech, my/qmtech) added support for qm_xc6slx16_sdram board
| * dae037cf (my/spisingle, spisingle) added spi 1-bit mode, code from litex
|/
* 1325aff6 (origin/master, origin/HEAD, master) correctly use result of Record.connect in Converter (#81)

Set default github username

$ git config --global credential.https://github.com.username danielkucera

Squash commits

git rebase -i <after-this-commit>

replace “pick” on the second and subsequent commits with “squash” or “fixup”

Ignore line endings

git config --global core.autocrlf true