Git submodules drive me batty! They are a great idea in theory however in practical application they are a pain in the butt to work with. I have a project that has accumulated over a dozen submodules over the past couple years. Switching branches and merging anything has become excruciating. This morning was the last straw.
Reset all git submodules
Here is a quick snippet that will reset all your git submodules to their most recent commit. Handy when something has happened such as a file permissions change that unintentionally affected the submodules. git submodule foreach –recursive git reset –hard
Compare a single file between git branches
Comparing a file between two git branches is quite easy. You can do it with both diff and difftool. Straight diff git diff BRANCH_ONE BRANCH_TWO — FILE Using difftool git difftool BRANCH_ONE BRANCH_TWO — FILE
Make an empty git commit
Occassionally I have need to mark a specific moment in a git repository. Often this mark is to call out a deployment point. If everything has already been committed I will use an “empty commit” as a marker. Git makes this quite easy and in fact it is built into the commit command. Run the
Autocomplete git branches and commands in bash
The tab completion for commands in bash is awesome, but it does not work for bash out of the box. Lucky for us it is relatively easy to get bash completion working. You will need two things, a copy of the completion script and an update to your bash profile. The completion script is available