Temple Coding

  • Home
  • Open Source
  • About
    • Books I am reading
    • About
RSS

Saving unfinished changes with Git

Posted on 10/11/2010 by vintem
No CommentsLeave a comment

The more I use Git, the more I like it. Fact.

You know when you are in the middle of something, it is not done yet, and someone call you with a bug for you to fix it? What do you do with your unfinished business?

Git has a command called stash. Stash is a separated area from your commits, which purpose is exactly that, to save unfinished work. And its use is very simple.

git stash save

This command saves the changes in the current working directory and clears the log to your last commit.

For instance, let’s say you have a project with a version 1 already done and you are in the middle of version 2, and of course, you have created a branch for that.

v2

Then, while you are in the middle of another feature, there’s a bug to fix in version 1. Your git status at this moment would look like this:

git_status

You can’t commit yet, because if you do that, the build will break, and your are to much of a responsible guy to do that, aren’t you? So what to do?

moron

Here’s when git stash comes to play. With the command: git stash save – you’ll have the following result:

stash

The buffer gets cleared, and you now can checkout version 1.0, fix the bug, commit it, get back to version 2.0 and rebase it.

When you reach that point just executes command: git stash pop – to get your unfinished changes back.

stash_pop

Done, your back in the game, exactly were you left it.

There are a lot more options within stash command. I recommend you take a look at git’s documentation.

Tweet
government,politics news,politics news,politics
Categories: Source Code Control | Tags: controle de versoes, git
Notice: This work is licensed under a BY-NC-SA. Permalink: Saving unfinished changes with Git
O livro eletrônico é só vantagem
Ruby for .NET Developers – part 2
  • Categories

    • .NET (1)
    • ASP.NET (1)
    • ASPNET MVC (15)
    • Blog (1)
    • Source Code Control (2)
    • Development (10)
    • Java (1)
    • JavaScript (2)
    • jQuery (1)
    • Reading (5)
    • Ruby (2)
    • Ruby on Rails (1)
    • Sem categoria (23)
    • Testing (4)
  • Language

    • English
    • Português
  • Tags

    agilidade asp.net asp.net mvc asp.net vc automapper blog code templates controle de versoes css dataaccess dependency injection ebook encoding eventos excecoes firebug git globalizacao hibernate iis ironruby jasypt java javascript jquery json leitura less mvccontrib qcon rails ruby selenium simpledata snippet stored procedures structuremap tdc templates testes testes integrados visualstudio vraptor windsor
© Temple Coding. Proudly Powered by WordPress | Nest Theme by YChong