4

Sometimes when running git stash pop there are merge conflicts that need to be resolved. This happens a lot when I have to stash/pop before/after switching branches.

The conflicts are no problem to deal with, but this has two annoying side effects:

  1. All changes coming from the stash are now staged and have to be unstaged

  2. stash@{0} is not dropped and has to be dropped manually

Looking for suggestions on how to make this process a little smoother.

SQB
  • 3,926
  • 2
  • 28
  • 49
Ken Liu
  • 22,503
  • 19
  • 75
  • 98

2 Answers2

0

If you are using stash as a means for you to switch branches and then just apply the stash, I can recommend using the -m option for checkout

git checkout -m master

Will switch to master and perform a merge of your changed files. This way you don't need to do

git stash
git checkout master
git stash pop
git reset HEAD .
rtn
  • 127,556
  • 20
  • 111
  • 121
  • Yes, but doesn't merging after a `stash pop` create a merge commit? I'd like to avoid that if possible. – Ken Liu Jun 15 '11 at 19:15
  • I'm trying to tell you that you don't have to use stash at all if you just want to switch between branches. Just do checkout with -m option and you are set. – rtn Jun 17 '11 at 09:35
-1

Use git stash drop - or git stash clear if you don't have anymore stashes to clear the stash you saved. You'll need to git reset --hard if you don't want anything from the stash or git reset HEAD . to clear what you staged.

I miss-read the initial question. Corrected now.

Hope this helps.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141