Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git magic tricks

Git magic tricks

A lightning talks with a few Git configuration magic tricks

Xavier F. Gouchet

April 04, 2018
Tweet

More Decks by Xavier F. Gouchet

Other Decks in Programming

Transcript

  1. ABOUT… XAVIER F. GOUCHET LEAD ANDROID ENGINEER AT WORKWELL FLUENT

    IN ANDROID SINCE CUPCAKE ON ALL SOCIAL NETWORKS @XGOUCHET 2
  2. FOREWORD EDIT THE CONFIG FILES : Local: /…/repo/.git/config Global (per

    user) : ~/.gitconfig System : /etc/gitconfig [group] property = value 3
  3. IN THE TERMINAL $ git config group.property "Foo" $ git

    config --global group.property "Bar" $ git config --system group.property "Baz" 4
  4. YOU'RE HERE ↓ [alias] # WTF was I working on

    earlier… ? wtf = "!git status --short --branch; echo -e '\nThe last 3 commits was :'; git lg -3 --numstat" 6
  5. SHORT TERM MEMORY LOSS [alias] # log only my commits

    mine = lg --author="$(git config user.email)" # log my commits since yesterday standup = !git mine --since yesterday 7
  6. TAKE OUT THE TRASH [alias] # dmb = delete-merged-branches dmb

    = "!git branch --no-color --merged | egrep -v "(^\*|master|develop)" | xargs -I{} git branch -d {}" 8
  7. WHAT'S UP, DOC ? [alias] update = "!git pull -r

    && git dmb && git wtf" sync = "!git pull -r && git push" 9
  8. REWRITING HISTORY [alias] # Amend last commit amend = commit

    --amend # Amend without prompting for a message update comend = commit --amend --no-edit # Create a fixup commit (git fixup 35d15a2) fixup = commit --fixup 10
  9. CAN I HAVE SOME MORE, PLEASE ? [alias] # never

    push force ! please = push --force-with-lease 11
  10. TO ERR IS HUMAN, BUT A REAL DISASTER NEEDS A

    GIT CLIENT [alias] # undo `git [add|rm] …` unstage = reset --mixed # undo `git commit …`, keep the changes uncommit = reset --soft HEAD^ # undo `git commit …`, drop the changes ⚠ rollback = reset --hard HEAD^ 12
  11. I HAVE SEXDAILY... DISLEXIA... DAMN AUTOCORRECT! [help] # execute the

    mistyped command after 50 deciseconds (5s) autoCorrect = 50 [alias] cehcout = checkout cmomit = commit 13
  12. AN ACCIDENT WAITING TO HAPPEN “Some fixes.” “Should work now…

    I think” “You won't believe what this developer did to fix the bug !” [alias] yolo = "!git add -a && commit -m "$(curl -s whatthecommit.com/index.txt)" 14
  13. WANT MORE ? 🔎 .gitconfig on GitHub gists 🔎 git

    aliases on GitHub or just Google If you type it more than twice, make an alias of it 15