Coder Social home page Coder Social logo

bartman / git-wip Goto Github PK

View Code? Open in Web Editor NEW
324.0 14.0 49.0 61 KB

help track git Work In Progress branches

Home Page: http://www.jukie.net/~bart/blog/save-everything-with-git-wip

Emacs Lisp 18.92% Shell 63.83% Python 5.17% Vim Script 12.09%

git-wip's Introduction

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.

git-wip's People

Contributors

abusalimov avatar bartman avatar bcarl avatar camdez avatar darwinawardwinner avatar dharmatech avatar diablotech avatar eiennohito avatar jeromebaum avatar purcell avatar robertkrimen avatar rsrchboy avatar tarsius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-wip's Issues

implement git wip list

This command will list all wip branches

$ git wip list
wip/foo
wip/bar

$ git wip list -v
wip/foo is 5 commits ahead of foo
wip/bar is 1 commit ahead of bar

Blog post link is broken

* About to connect() to www.jukie.net port 80 (#0)
*   Trying 208.68.38.196... connected
> GET /bart/blog/save-everything-with-git-wip HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: www.jukie.net
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/html
< Content-Length: 369
< Date: Thu, 15 Oct 2015 13:46:25 GMT
< Server: lighttpd/1.4.35
< 
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 - Internal Server Error</title>
 </head>
 <body>
  <h1>500 - Internal Server Error</h1>
 </body>
</html>
* Connection #0 to host www.jukie.net left intact
* Closing connection #0

ATM the post is accessible at Internet Archive but maybe there is a better location to link to.

Ongoing development of git-wip-mode?

@bartman, are you planning to keep maintaining git-wip-mode, or is it deprecated in favor of magit-wip as suggested in #14?

The reason I ask is that I made some enhancements to git-wip-mode before Iearning about magit-wip. One addresses #21, and another fixes the problem that git-wip-after-save sends the message "Wrote and git-wip'd" even if the asynchronous process calling git-wip fails. I can send over a pull request if there is interest in ongoing development, though in that case, it would be good to take action on PR #12, since my changes affect some of the same functions.

Thanks.

implement git wip delete

Should be able to delete wip branches.

$ git wip list
wip/foo
wip/bar

$ git wip delete wip/foo
$ git wip delete bar

support running out of working tree

If you start vim in ~/project/a, and then edit ~/project/b/a.c saving will result in lots of errors.

git wip should detect that it's given a path in a different work tree and switch to it before running git commands.

implement git wip info

Should print wip branch name and number of commits on it.

Maybe something like this....

$ git wip info
wip/topic is 5 commits ahead of topic

missing git-sh-setup and require_work_tree

In git-wip script, what is the purpose of following:

  • line no. 40: ". git-sh-setup"
  • line no. 42: "require_work_tree"

There also doesn't seem to have any functions or scripts in the code implementing these. What am I doing wrong?

absolute file path for setup

The setup script path should be made absolute:

diff --git a/git-wip b/git-wip
index 4a8d80b..3d1dba9 100755
--- a/git-wip
+++ b/git-wip
@@ -37,7 +37,7 @@ Options for log:
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=

-. git-sh-setup
+. "$(git --exec-path)/git-sh-setup"

 require_work_tree

Marc

Development stalled?

Hi

It seems like there has been a lot of development or merges of pull requests lately. That is sad because this a nice little tool. If you want, I can help you maintain it? I don't have a lot of time either, but I could look at the pull requests and merge them in if they make sense. I also have an integration with wip and Facebook's watchman, I at least find helpful and could share as it is done with the vim plugin.

This is in no way a criticism, but I know when life gets in the way and tuits are hard to find, so I just wanna help keep this project alive if you're interested.

\o baest

Sync between machines and users

Thanks for the script, really close to what I'm looking for but it's currently too similar to what can be achieve with undotree.

Wondering how this would work when editor save pushes to a remote as well. I'm trying to make it so when I work on one machine I can switch to another machine or another user on another machine can get access to my WIP and pick up where I left off.

git-wip currently unsuable for emacs users

Hi, git-wip is current unusable for emacs users. It would be great if you could take a look at the issues list. I think merging in the changes in #11 should do the trick as far as emacs support goes.

If you no longer want to maintain this tool you should consider giving someone else commit acces or even transfer ownership. It's too awesome to let die. I'm sure some of the other committers would be willing to step up.

grunt integration

this would be great if it was integrated with grunt so that you could just run grunt watch command and it would call git wip every time the watched file list was changed!

no changes

I seems that git-wip does not detect changes, it shows no changes but there is actually changes, I used the script in master and next branches, no success

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.