git_commands.md

June 29, 2021 ยท View on GitHub

A useful collection of Git commands Back

  1. List all authors inside a project:

    git shortlog --summary --numbered --email 
    
    git shortlog -sne 
    

    To show all branches:

    git shortlog -sne -all 
    
  2. List logs with a colourful graph:

    git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ai) %C(bold blue)<%an>%Creset' --abbrev-commit
    
  3. Squash all commits into one:

    !f(){ git reset $(git commit-tree HEAD^{tree} -m \"${1:-A new start}\");};f "commmit message" 
    
  4. Show lines of differences between two commits:

    git diff --shortstat