• Stars
    star
    323
  • Rank 126,154 (Top 3 %)
  • Language
    Shell
  • Created over 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

help track git Work In Progress branches

About

git-wip is a script that will manage Work In Progress (or WIP) branches. WIP branches are mostly throw away but identify points of development between commits. The intent is to tie this script into your editor so that each time you save your file, the git-wip script captures that state in git. git-wip also helps you return back to a previous state of development.

Latest git-wip can be obtained from github.com. git-wip was written by Bart Trojanowski. You can find out more from the original blog post.

WIP branches

Wip branches are named after the branch that is being worked on, but are prefixed with 'wip/'. For example if you are working on a branch named 'feature' then the git-wip script will only manipulate the 'wip/feature' branch.

When you run git-wip for the first time, it will capture all changes to tracked files and all untracked (but not ignored) files, create a commit, and make a new wip/topic branch point to it.

--- * --- * --- *          <-- topic
                 \
                  *        <-- wip/topic

The next invocation of git-wip after a commit is made will continue to evolve the work from the last wip/topic point.

--- * --- * --- *          <-- topic
                 \
                  *
                   \
                    *      <-- wip/topic

When git-wip is invoked after a commit is made, the state of the wip/topic branch will be reset back to your topic branch and the new changes to the working tree will be caputred on a new commit.

--- * --- * --- * --- *    <-- topic
                 \     \
                  *     *  <-- wip/topic
                   \
                    *

While the old wip/topic work is no longer accessible directly, it can always be recovered from git-reflog. In the above example you could use wip/topic@{1} to access the dangling references.

git-wip command

The git-wip command can be invoked in several differnet ways.

  • git wip

    In this mode, git-wip will create a new commit on the wip/topic branch (creating it if needed) as described above.

  • git wip save "description"

    Similar to git wip, but allows for a custom commit message.

  • git wip log

    Show the list of the work that leads upto the last WIP commit. This is similar to invoking:

    git log --stat wip/$branch...$(git merge-base wip/$branch $branch)

Installation

Download the script from the GitHub page:

git clone git://github.com/bartman/git-wip.git

Add git-wip to your $PATH:

mkdir -p ~/bin
cp git-wip/git-wip ~/bin/

editor hooking

To use git-wip effectively, you should tie it into your editor so you don't have to remember to run git-wip manually.

vim

To add git-wip support to vim you can install the provided vim plugin. There are a few ways to do this.

(1) If you're using Vundle, you just need to include the following line in your .vimrc.

Bundle 'bartman/git-wip', {'rtp': 'vim/'}

(2) You can slo copy the git-wip.vim into your vim runtime:

cp vim/plugin/git-wip ~/.vim/plugin/git-wip

(3) Alternatively, you can add the following to your .vimrc. Doing so will make it be invoked after every :w operation.

augroup git-wip
  autocmd!
  autocmd BufWritePost * :silent !cd "`dirname "%"`" && git wip save "WIP from vim" --editor -- "`basename "%"`"
augroup END

The --editor option puts git-wip into a special mode that will make it more quiet and not report errors if there were no changes made to the file.

emacs

To add git-wip support to emacs add the following to your .emacs. Doing so will make it be invoked after every save-buffer operation.

(load "/{path_to_git-wip}/emacs/git-wip.el")

Or you may also copy the content of git-wip.el in your .emacs.

sublime

A sublime plugin was contributed as well. You will find it in the sublime directory.

recovery

Should you discover that you made some really bad changes in your code, from which you want to recover, here is what to do.

First we need to find the commit we are interested in. If it's the most recent then it can be referenced with wip/master (assuming your branch is master), otherwise you may need to find the one you want using:

git reflog show wip/master

I personally prefer to inspect the reflog with git log -g, and sometimes with -p also:

git log -g -p wip/master

Once you've picked a commit, you need to checkout the files, note that we are not switching the commit that your branch points to (HEAD will continue to reference the last real commit on the branch). We are just checking out the files:

git checkout ref -- .

Here ref could be a SHA1 or wip/master. If you only want to recover one file, then use it's path instead of the dot.

The changes will be staged in the index and checked out into the working tree, to review what the differences are between the last commit, use:

git diff --cached

If you want, you can unstage all or some with git reset, optionally specifying a filename to unstage. You can then stage them again using git add or git add -p. Finally, when you're happy with the changes, commit them.

More Repositories

1

elfgpg

sign elf binaries with GPG
C
17
star
2

urxvt-scripts

my urxvt scripts
Perl
17
star
3

dot-files

track dot-files in $HOME/etc directory
16
star
4

git-case

ticker tracker for git
Shell
11
star
5

wmii-lua

Wmii extended with lua scripts
Lua
9
star
6

clinvoice

command line invoicing tool
Shell
9
star
7

wmii

window manager improved 2 (import from mercurial)
C
7
star
8

dot-uzbl

my uzbl files
JavaScript
7
star
9

flashbench

Tool for benchmarking and classifying flash memory drives
C
5
star
10

notmuch

Notmuch is not much of an email program.
C
5
star
11

negative

generate presentation slides from inkscape svg files
C
5
star
12

libixp

minimalist 9P client/server library for Unix (import from mercurial)
C
5
star
13

syncmaildir

Sync Mail Dir (smd) is a set of tools to synchronize a pair of mailboxes in Maildir format.
C
4
star
14

event-loop-benchmark

compare relative performance of libev libevent libuev libuv picoev
C
4
star
15

oops-code

convert linux kernel oops output to assembly
C
3
star
16

0x10c-tools

tools for the 0x10c DCPU-16 processor (C and lua)
C
3
star
17

parallel-fetch

simple stress program for web servers
C
3
star
18

luamenu

dmenu fork with lua support
C
3
star
19

progression-app-perl

decode backup files from the Progression app
Perl
2
star
20

bartman.github.com

This repo holds files for bartman.github.io
HTML
2
star
21

snippets

just a bunch of random code
C
2
star
22

history-select.nvim

nvim lua dialog box with a history file, based on telescope UI
Lua
2
star
23

resume

my resume repo
Shell
1
star
24

blot

📈 console graphing / plotting library written in C
C
1
star
25

time-my-presentation

Script I use to time how long it took me to present my slides.
Perl
1
star
26

wxrtools

wxrtools
C
1
star
27

zonegen

generates DNS internal/external zone files from template
1
star