Git tips from stackoverflow

Sometimes git is confusing, and things that should be simple quickly look like magic incantations. Here are two such cases
by Jonathan Foucher

For referencing: permalink to this article. Published • 09 Apr 2012

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
blog comments powered by Disqus