how to pop git stash without triggering an auto-merge -
the short version of question this: how can pop git
stash without triggering auto-merge?
now longer version...
consider following toy example of alternative git stash ... + git pull ... + git pop
.
first, git status
shows modification in working directory tracked file foo
.
# on branch master # changes not staged commit: # (use "git add <file>..." update committed) # (use "git checkout -- <file>..." discard changes in working directory) # # modified: foo # no changes added commit (use "git add" and/or "git commit -a")
now, in order reset working directory clean state, pre-requisite running git pull
, temporarily rename modified file foo
(to untracked name), , restore version of foo
in head
...
% mv foo foo.$(date +%y%m%dt%h%m%s) % git checkout foo % git status # on branch master # untracked files: # (use "git add <file>..." include in committed) # # foo.20130508t110014 nothing added commit untracked files present (use "git add" track)
ok, run git pull
, which, sake of example, may assume fast-forward:
% git pull
lastly, restore temporarily renamed foo
.
% mv foo.20130508t110014 foo
...and i'm to
% git status # on branch master # changes not staged commit: # (use "git add <file>..." update committed) # (use "git checkout -- <file>..." discard changes in working directory) # # modified: foo #
this "moral equivalent" of git stash save + git pull + git stash pop
, except former, , not latter, is immune "merge conflicts", one:
% git stash save 'wip' % git pull % git stash pop auto-merging foo conflict (content): merge conflict in foo
how can replicate rename-checkout-pull-rename
sequence above using git stash save + ... + git stash pop
, without triggering auto-merge?
edit: incidentally, rename-checkout-...-rename
routine more closely represents expect command called stash
. iow: save state of working directory now, , replace later. there's no "merge" in picture.
stash
merges, that's how works.
you can achieve non-merge-y stash with write-tree
read-tree
, checkout-index
. here's worked example doing achieve pristine test environment.
to brute-force no-merge stash apply, e.g.
git read-tree stash^{tree} git checkout-index -af
Comments
Post a Comment