Git cheatsheet

Flow

1
2
[Working directory] -> [Staging Area (Index)] -> [Repository] -> [Remote]
                   add                      commit           push

Basic

Diff

Merge

Revert

Stash & Patch

Tags

Info

Bisect

  1. checkout repo at bad commit
  2. start bisect
  3. mark known good commit
  4. checkout commit in between bad and good (done by bisect automatically)
  5. check if commit is still bad
  6. repeat 4-5 until found the guilty commit
  7. stop bisect (checkout to previous state)

Submodules

Remove submodule

  1. git rm [submodule]
  2. rm -rf .git/modules/[submodule]
  3. git config --remove-section submodule.[submodule]
  4. git commit

Binary files - LFS (Large File Storage)

  1. git lfs install : install LFS, once per user
  2. git lfs track "*.[file type]" : add file type to track with LFS
  3. git add .gitattributes : make sure that this is tracked

Config

1
2
3
4
5
6
7
8
9
[user]
    name = [FIRST NAME] [LAST NAME]
    email = [EMAIL]
[credential]
    helper = store
[log]
    date = local
[format]
    pretty = format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s

GitHub password

GitHub is no longer accepting account passwords, need to use PAT (Personal Access Token).