Piku’s Blog

June 13, 2008

Git trick

Filed under: Git — Tags: , , — Mihai @ 11:11 pm

A friend asked me about an error he had while trying ‘git pull, it was saying that file X was not uptodate.

For git pull (actually for merge) you need to not have anything uncommited (either commit or reset). But he did not wanted to commit because he didn’t finished working neither reset because he would lose his work.

There is another way, git stash: Git stash saves your modifications away and gives you a clean working dir. Use ‘git stash <optional name>‘ to create a stash. With ‘git stash list‘ you can view your stashes, ‘git stash show <name>‘ to view a specific stash and ‘git stash apply <name>‘ to apply it.

In his case he needed to run:

git stash work
git pull
git apply work


  1. I’ve found that I prefer to use ‘git stash pop’, as apply leaves the stash stack intact. There are probably times to keep the stack around, but I haven’t run into one yet.

    Comment by Michael Johnson — June 16, 2008 @ 7:18 pm

  2. Yes, stash pop also deletes the stash, and automatically picks the last stash if you do not specify a name.

    Comment by Piku — June 16, 2008 @ 7:42 pm

  3. […] Git trick « Piku’s Blog. Related posts:Welcome to my New BlogMy favourite blog at the moment: […]

    Pingback by Git trick « Piku’s Blog – How to use Git Stash | Chaosplay — July 30, 2009 @ 12:06 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: