Piku’s Blog

June 13, 2008

Git trick

Filed under: Git — Tags: , , — Piku @ 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
About these ads

3 Comments »

  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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: