Geeky Nuggets

Git tips from stackoverflow

April 09, 2012 | 1 Minute Read

Here are some pretty cool and very useful git tricks I learnt by searching or reading stackoverflow. Most of them are operations that should be pretty easy to do, and seem pointlessly complicated. The second one is an excellent example of both the flexibility and the lack of user friendliness of the git UI

Prevent a file from being commited, ever

Git: Never Commit Changed Files (But still keep original revisioned.)

    git update-index --assume-unchanged <file>

To make it commitable again run

    git update-index --no-assume-unchanged <file>

Commits no yet pushed

Viewing Unpushed Git Commits

If you want to see all commits on all branches that aren’t pushed yet, you might be looking for something like this:

    git log --branches --not --remotes

And if you only want to see the most recent commit on each branch, and the branch names, this:

    git log --branches --not --remotes --simplify-by-decoration --decorate --oneline