git gui: add pull and stash commands

It was not easy and took some time but I learned to like git gui tool. It has raw interface and manners but it can be used for most of basic git operations. It is also available everywhere and is deterministic and reliable.

But time to time I miss more advanced commands. Fortunatelly there is possibility to add new commands via gitconfig file. Typically located at ~/.gitconfig path. Then these commands appears in Tools main menu.

First thing I miss is stash functionality. It can be added by following entries added to mentioned file:

[guitool "Stash/show"]
cmd = git stash show -p

[guitool "Stash/list"]
cmd = git stash list

[guitool "Stash/pop"]
cmd = git stash pop

[guitool "Stash/drop"]
cmd = git stash drop
confirm = yes

[guitool "Stash"]
cmd = git stash

It is also annoying to do fetch+merge operations instead of pull. Unfortunatelly pull needs name of remote and branch as parameters, so you need a bit of scripting:

[guitool "Pull"]
cmd = git pull $(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD) | tr / " ")

It automatically select remote branch of tracking branch. Maybe it won’t work correctly in setups with more remote branches but for single remote it works fine.

In case you need this commands on all computers where repository is cloned, you can place configuration above into file .git/config in your repository.


Tags:  GIT