Note that there are some explanatory texts on larger screens.

plurals
  1. POgit stash while amending last commit (in gui) - pop pops nothing
    primarykey
    data
    text
    <p>So I had some unstaged changes and some staged ones. I issued</p> <pre><code>Welcome to Git (version 1.8.3-preview20130601) $ git stash save --keep-index Saved working directory and index state WIP on master: ab0d18d Setup of alarms f or network service + Logging exceptions + long arithmetic HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions + long arithmetic $ git stash Saved working directory and index state WIP on master: ab0d18d Setup of alarms f or network service + Logging exceptions + long arithmetic HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions + long arithmetic </code></pre> <p>Then I hit amend last commit <strong>in the gui</strong> to split the ab0d18d commit into smaller ones. I unstaged some of the files and I hit</p> <pre><code>$ git stash save --keep-index Saved working directory and index state WIP on master: ab0d18d Setup of alarms f or network service + Logging exceptions + long arithmetic HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions + long arithmetic </code></pre> <p>Repeated the above procedure :</p> <pre><code>$ git stash save --keep-index Saved working directory and index state WIP on master: ab0d18d Setup of alarms f or network service + Logging exceptions + long arithmetic HEAD is now at ab0d18d Setup of alarms for network service + Logging exceptions + long arithmetic </code></pre> <p>Then I edited the commit message and I committed. Then I issued <code>git stash pop</code> to start getting back my stashes and committing them one by one.</p> <pre><code>$ git stash pop # On branch master # Untracked files: # (use "git add &lt;file&gt;..." to include in what will be committed) # # TODO.txt nothing added to commit but untracked files present (use "git add" to track) Dropped refs/stash@{0} (43facd88ea3548071b196324523bd017d680d6dd) </code></pre> <p>Disaster !</p> <p>I had backups happily (long live dropbox)</p> <p>2 questions :</p> <ul> <li>what did I do wrong ?</li> <li>how should one recover from such a scenario ?</li> </ul> <p>EDIT : gitk after I restored the changes (the amended commit is the SETUP ALARMS one)</p> <p><img src="https://i.stack.imgur.com/CToPE.jpg" alt="enter image description here"></p> <p><strong><em>EDIT</em></strong></p> <p>Found a way to reproduce the problem - will be amending it (probably only the last part is needed - was trying to reproduce my original scenario exactly) but for starters :</p> <pre><code>mkdir test_stash; cd test_stash;git init echo f1 &gt;&gt; f1 ; echo f2 &gt;&gt; f2 ; echo f3 &gt;&gt; f3 ; echo f4 &gt;&gt; f4 ; echo f5 &gt;&gt; f5 git add f1 f2 f3 f4 f5 git commit -m base123 echo change f1 to be amended &gt;&gt; f1 echo change f2 to be amended &gt;&gt; f2 echo change f3 to be amended &gt;&gt; f3 git add . git commit -m tobeamended123 echo change f4 &gt;&gt; f4; git add f4 echo change f5 &gt;&gt; f5 git stash save --keep-index git stash git gui &amp; </code></pre> <p>Now hit amend commit <strong><em>in the gui</em></strong>. Not sure to which command it corresponds to but <code>git commit --amend</code> does not do the trick. </p> <p><img src="https://i.stack.imgur.com/iBGbr.jpg" alt="enter image description here"></p> <p>While in the amend state unstage file f3 <strong><em>in the gui again</em></strong> (click on it so it moves on the unstaged area - would be <code>git reset HEAD f3</code> but this does not work either) then</p> <pre><code>git stash save --keep-index git commit -m amended # not really amended - a new commit altogether git stash pop </code></pre> <p>Getting :</p> <pre><code># # On branch master nothing to commit, working directory clean Dropped refs/stash@{0} (898687d73b65ccc9e10cd826bc12fda1a4759651) </code></pre> <p>Expecting : the f3 modifications to show up</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload