Skip to content

Latest commit

 

History

History
214 lines (140 loc) · 3.27 KB

PITCHME.md

File metadata and controls

214 lines (140 loc) · 3.27 KB

Git Magic Tricks

CodeMobile UK 2018


About… Xavier F. Gouchet

Lead Android Engineer at WorkWell

Fluent in Android since Cupcake

@xgouchet on , , , , …

Foreword

Edit the config files :

  • Local /…/repo/.git/config
  • Global (per user) : ~/.gitconfig
  • System : /etc/gitconfig
[group]
  property = value

In the terminal

$ git config group.property "Foo"
$ git config --global group.property "Bar"
$ git config --system group.property "Baz"

Aliases

[alias]
  lg = log --pretty=format:"%Cyellow%h %ad %Cwhite%s"
$ git lg

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"

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

Take out the trash

[alias]
  # dmb = delete-merged-branches
  dmb = "!git branch --no-color --merged | 
          egrep -v "(^\*|master|develop)" | 
          xargs -I{} git branch -d {}"

What's up, doc ?

[alias]
  update = "!git pull -r && git dmb && git wtf"

  sync = "!git pull -r && git push"

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

Can i have some more, please ?

[alias]
  # never push force !
  please = push --force-with-lease

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^

I have sexdaily...

dislexia...
[help]
  # execute the mistyped command after 50 deciseconds (5s)
  autoCorrect = 50

Damn autocorrect!

[alias]
  cehcout = checkout
  cmomit = commit

An accident waiting to happen

[alias]
  yolo = "!git add -a && 
        commit -m "$(curl -s whatthecommit.com/index.txt)"
  • “Some fixes.”
  • “Should work now… I think”
  • “You won't believe what this developer did to fix the bug !”

Want more ?

  • .gitconfig on gists
  • git aliases on or just

If you type it more than twice, make an alias of it


Demo time


Demo time


Questions


Questions


Git Hooks

 


Git Hooks

Next time… maybe ?

Thank you for your attention