Last Updated: February 25, 2016
·
6.326K
· mchaisse

WIP+git+oh-my-zsh: improve your branch switching

Tired of seeing "temporary commit" in your git logs?
Use the Work in Progress feature, now available in Oh-my-zsh!
When you are currently working on your branch and need to checkout or change the code on another one, you have to commit your current changes before switching branches.

Solution:

Pause your work by creating a WIP (Work in Progress) commit. It creates a temporary "wip" commit that can be easily uncommit when you want to go back to work with the same state.

Picture

Commands

> gwip
# Commit temporary changes

> gunwip
# Uncommit temporary changes

Notification

A notification appears on your prompt if you are in a WIP branch (preventing unwanted temporary commits). All you have to do is unwip it.

Picture

This notification is actually available by default on the "gallois" theme. To add this notification on your own theme, just add:

$(work_in_progress)

in your own theme:

~/.oh-my-zsh/themes/mytheme.zsh-theme

The $(work_in_progress) function simply return a string "WIP!!" if current branch is in wip.

Tips

1. Add some colors to your notifications. Example:
%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}

2. To change your current theme, open the "~/.zshrc" file, find and edit the line:
ZSH_THEME="gallois"

May the efficiency be with you!

2 Responses
Add your response

What about git stash and pop? http://git-scm.com/book/en/Git-Tools-Stashing

over 1 year ago ·

This is another approach of the wip feature (and a good one because of the git native implementation). I used it before.
Unfortunately, I don't know why, sometimes my stash disappeared or because of a mistake, were applied to another branch than the original one.
Moreover, when you decide to go back to your working branch, you could forget (days after) that you created a stash.
With the above method, you'll be notified on your branch status, and be sure that your work will never be lost.
In the case you want to create a wip over another wip (which is very messy), I'm agree with you, stash with its history feature is the most efficient approach.

over 1 year ago ·