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

Git Aliases

Git Aliases

One man's take on using bash profile aliases for git.

Andrew Thal

April 09, 2012
Tweet

More Decks by Andrew Thal

Other Decks in Technology

Transcript

  1. + Summary n  Workflow as taught by Tom Copeland n 

    Based off of “A Git Workflow for Agile Teams” n  Rein Henrichs n  Reinh.com
  2. + How It Works my fork feature branch production master

    branch Remote Local pull pull request push create new/rebase
  3. + In Practice n  Pull from production n  Checkout new

    branch n  Make / commit changes n  Commit early and often n  Rebase / Squash commits n  Push to your branch n  Pull request n  git pull origin master n  git checkout -b my-branch n  git add changed-file n  git commit –m “message” n  git fetch origin master n  git rebase –i origin/master n  git push my-fork my-branch Task Command(s)
  4. + Remotes Action Standard Alias Keystrokes Saved Show git remote

    –v show gres 16 Add git remote add grea 12 Remove git remote rm grer 9 Clone git clone gcl 6 Action Standard Alias Keystrokes Saved Show git remote –v show gres 16 Add git remote add grea 12 Remove git remote rm grer 9 Action Standard Alias Keystrokes Saved Show git remote –v show gres 16 Add git remote add grea 12 Action Standard Alias Keystrokes Saved Show git remote –v show gres 16 Action Standard Alias base = gre Keystrokes Saved my fork feature branch production master branch Remote Local
  5. + Branch Management Action Standard Alias Keystrokes Saved Branch List

    git branch gb 8 Checkout git checkout go 10 Make New git checkout -b gbn 12 Delete git branch -d gbd 10 Action Standard Alias Keystrokes Saved Branch List git branch gb 8 Checkout git checkout go 10 Make New git checkout -b gbn 12 Action Standard Alias Keystrokes Saved Branch List git branch gb 8 Checkout git checkout go 10 Action Standard Alias Keystrokes Saved Branch List git branch gb 8 Action Standard Alias base = gb Keystrokes Saved my fork feature branch production master branch Remote Local
  6. + Check Status Action Standard Alias Keystrokes Saved Status git

    status gst 8 Log (formatted) git log -- pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short glo 63 Log (all branches formatted) git log -- pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short --all gloa 68 Gitk gitk gk 2 Action Standard Alias Keystrokes Saved Status git status gst 8 Log (formatted) git log -- pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short glo 63 Action Standard Alias Keystrokes Saved Status git status gst 8 Log (formatted) git log -- pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short glo 63 Log (all branches formatted) git log -- pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short --all gloa 68 Action Standard Alias Keystrokes Saved Status git status gst 8 Action Standard Alias Keystrokes Saved my fork feature branch production master branch Remote Local
  7. + Making Changes Action Standard Alias Keystrokes Saved Add One

    File git add ga 5 Add All Files git add -A gaa 7 Reset Add git reset HEAD greset 12 Stash git stash gs 7 Apply Stash git stash apply gsa 12 Action Standard Alias Keystrokes Saved Add One File git add ga 5 Add All Files git add -A gaa 7 Reset Add git reset HEAD greset 12 Stash git stash gs 7 Action Standard Alias Keystrokes Saved Add One File git add ga 5 Add All Files git add -A gaa 7 Undo Add git reset HEAD gau 12 Action Standard Alias Keystrokes Saved Add One File git add ga 5 Add All Files git add -A gaa 7 Action Standard Alias Keystrokes Saved Add One File git add ga 5 Action Standard Alias base = ga, gs Keystrokes Saved my fork feature branch production master branch Remote Local
  8. + Committing Action Standard Alias Keystrokes Saved Commit w/ Message

    git commit –v -m gcm 13 Amend a Commit git commit –v --amend -m gca 21 Undo a Commit git revert HEAD gcu 12 Action Standard Alias Keystrokes Saved Commit w/ Message git commit –v -m gcm 13 Amend a Commit git commit –v --amend -m gca 21 Action Standard Alias Keystrokes Saved Commit w/ Message git commit –v -m gcm 13 Action Standard Alias base = gc Keystrokes Saved my fork feature branch production master branch Remote Local
  9. + Moving Code Action Standard Alias Keystrokes Saved Pull git

    pull gl 6 Fetch git fetch gf 7 Rebase git rebase grb 7 Interactive Rebase git rebase -i grbi 9 Action Standard Alias Keystrokes Saved Pull git pull gl 6 Fetch git fetch gf 7 Rebase git rebase grb 7 Action Standard Alias Keystrokes Saved Pull git pull gl 6 Fetch git fetch gf 7 Action Standard Alias Keystrokes Saved Pull git pull gl 6 Action Standard Alias Keystrokes Saved Action Standard Alias Keystrokes Saved Pull git pull gl 6 Fetch git fetch gf 7 Rebase git rebase grb 7 Interactive Rebase git rebase -i grbi 9 Push git push gp 6 my fork feature branch production master branch Remote Local
  10. + Git Aliases? n  ~/.gitconfig n  git_ (4 chars) n 

    git aliases only n  ~/.bash_profile n  g (1 char) n  compound aliases, all in one place git aliases bash aliases
  11. + A Minimum Workflow 55 Keystrokes Saved vs. full commands

    29 Keystrokes Saved vs. git aliases n  git pull origin master n  git checkout -b my-branch n  git add changed-file n  git commit –m “message” n  git fetch origin master n  git rebase -i origin/master n  git push my-fork my-branch n  git l origin master n  git co -b my-branch n  git a changed-file n  git ci –m “message” n  git f origin master n  git rb -i origin/master n  git p my-fork my-branch n  gl origin master n  gnb my-branch n  ga changed-file n  gcm “message” n  gf origin master n  grbi origin/master n  gp my-fork my-branch
  12. + An “Average” Workflow 96 Keystrokes Saved vs. full commands

    51 Keystrokes Saved vs. git aliases n  git pull origin master n  git checkout -b my-branch n  git add changed-file n  git commit –m “message” n  git add changed-file n  git commit –m “message” n  git log --all n  git checkout master n  git pull origin master n  git checkout my-branch n  git rebase -i origin/master n  git push my-fork my-branch n  git l origin master n  git co -b my-branch n  git a changed-file n  git ci –m “message” n  git a changed-file n  git ci –m “message” n  git log –all n  git co master n  git l origin master n  git co my-branch n  git rb -i origin/master n  git p my-fork my-branch n  gl origin master n  gnb my-branch n  ga changed-file n  gcm “message” n  ga changed-file n  gcm “message” n  gloa n  go master n  gl origin master n  go my-branch n  grbi origin/master n  gp my-fork my-branch
  13. + Do the Math 96 Keystrokes / Avg 5 chars/word

    / Avg 40 WPM * 24 Hungry Academy Participants = 11.5 Minutes Saved in an Average Workflow > 2 Pomodoro Breaks
  14. + alias deals='cd ~/Projects/deals' alias pipeline='cd ~/Projects/pipeline' alias canes="cane --style-glob

    '**/*.rb' --abc-glob '**/*.rb'" alias gd='git diff | e' alias bp='e ~/.bash_profile'