Git tips

Git tips and tricks.

Formatted list of recent commits

git for-each-ref \
  --sort=committerdate refs/remotes/ \
  --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

Git add interactive - select parts of your code to add

git add -i

Add files by wildcard

git add *.css

git add *users*

Add deleted files by wildcard

git add $(git ls-files --deleted | grep *users*)

Undo file checkout

Running git checkout on a modified file throws away the changes.

You can use your IDE to view local file changes to recover the modifications, if your IDE has this feature.

Try an undo in the editor.

Level
Topics