Advanced Git CLI

March 07, 2022

Learning Git

  1. https://gitimmersion.com/ really good walk-through of concepts.
    • A bit dated but holds up well
    • Interactive
  2. https://frontendmasters.com/courses/git-in-depth/ Advanced Git Course
    • Really in depth, advanced topics
  3. https://git-scm.com/book/en/v2 Pro Git Book
    • Reference style book

Zsh and Friends

Configure Zsh and Git

  1. Update local git to latest with brew
  2. Install Oh My Zsh
  3. Open a new terminal and type git che<tab>, autocompletion should work

Inspect Aliases Provided

alias show all aliases

alias | grep git show all git aliases

Top Examples

.. shortcut to nav up a dir

gst git status

gcmsg git commit -m ...

g git

gfa git fetch --all --prune

grbi git rebase --interactive

gwip commit changes, skip ci and label [WIP]

gunwip reset HEAD, stage WIP changes

gco and gco -b git checkout [-b] <branch>


Viewing State

gst

  • This is 'tracking' against 'upstream/master' (source, master)
  • Shows the count of commits ahead/behind, will show diverged branches
  • Fast forwarded means no merge-commit needed (clean history)

gb -vv

  • Shows each branch, tracking, ahead/behind counts

gb -rv

  • Shows remote branches

Tracking Branches


Keeping Repos Up To Date

gfa # git fetch --all --prune

gwip/gunwip


Merge Lockfiles

  1. Merge package.json, run npm install, continue merge

-- OR --

https://www.npmjs.com/package/npm-merge-driver


TK

rerere post merge install gh/hub gwip ga -p rebase fork and pull git configs