18

I am looking for a GUI for stashing and stash popping files in git, with the ability to do so for individual modified files. I know there is a command line way to do so, seen here, but I am looking for a graphical way. I don't care so much about stashing individual files, but more about popping/applying. I am running on Windows 7.

7
  • Unfortunately, your question is off-topic. Stack Overflow is not about software recommendations.
    – jub0bs
    Commented Apr 14, 2015 at 19:31
  • 1
    @Jubobs, okay, I thought of it as a "I need a way to solve my specific problem", not "which git gui client is the best".
    – Chance
    Commented Apr 14, 2015 at 19:39
  • Your OS? On Windows, GitExtensions could do that...
    – Philippe
    Commented Apr 14, 2015 at 20:33
  • 1
    You have a problem but you are looking for the solution in the wrong direction. git stash was designed for a different thing (it is explained in the first paragraph of its documentation). You can do what you want (and in a more flexible way than stashing) if you create a new branch and commit the changes on it (in any amount of combination you want) until you reach the status you desire. Then just checkout the previous branch and you're done.
    – axiac
    Commented Apr 15, 2015 at 8:36
  • 1
    @axiac, I think you are right. I'm using git coming from Perforce, so I'm trying to make stash fit in the 'shelve' mold, but I think branching is the better way to do it. Tied to this is that git extensions sort of makes a branch out of my stashes, so I may be able to stash but treat it like a branch when grabbing individual files.
    – Chance
    Commented Apr 15, 2015 at 13:09

3 Answers 3

17

I saw a recommendation here to add the Stash commands as a menu to "Git GUI" in your <USER HOME directory>\.gitconfig.

[guitool "Stash/show"]
  cmd = git stash show -p
[guitool "Stash/list"]
  cmd = git stash list
[guitool "Stash/pop"]
  cmd = git stash pop
[guitool "Stash/drop"]
  cmd = git stash drop
  confirm = yes

I also added one more command to do the stashing (to use, you must first stage--but not commit--the files you wish stashed in order for Git to perform the required "add"):

[guitool "Stash"]
  cmd = git stash

(Note that I chose to have "stash" not appear as a submenu, but you could do so.)

You can also add commands through Git GUI itself via Tools->Add.

Stashing can be helpful if you just want to put the files out of mind quickly without bothering to think of a branch name.

1
  • Doesn't look too helpful, as all the command output is displayed in an extra popup window without all the niceties such as a colored diff.
    – nyi
    Commented Apr 22 at 11:37
6

The documentation of git stash says:

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

It provides very little support1 to handle individual files because its purpose is to safely store your current changes and quickly bring your working tree to a clean state (i.e. as it was immediately after your last commit on the current branch).

You can do what you want (and in a more flexible way than stashing) if you create a new branch and commit the changes on it (in any amount or combination you want) until you reach the status you desire. Then just checkout the previous branch and you're done.

This approach allows you to merge the changes into the current branch later, to cherry-pick only some commits or even some files from them.


1 git stash save provides the option --patch that allows the user to interactively selects hunks from the diff between HEAD and the working tree to be stashed. It allows fine control over what is added to the stash.

Extra discussion

You say:

I'm using git coming from Perforce, so I'm trying to make stash fit in the 'shelve' mold, but I think branching is the better way to do it. Tied to this is that gitextensions sort of makes a branch out of my stashes, so I may be able to stash but treat it like a branch when grabbing individual files.

Internally, each stash is stored as a commit linked to the commit that was the HEAD at the moment when the stash was created, but not linked to the previous stash (if any). The list of stashes is stored as meta-data; the stashes are not linked in a (hidden) branch.

More, git stash create allows the creation of a stash without adding it into the list of stashes. It is provided for scripting and "probably not the command you want to use" (I quoted from the documentation).

4
  • thanks. To clarify, I don't think the stash really is like a branch, but git extensions makes it appear so - which can be good or bad. git extensions provides a layer of abstractions, and sometimes it's not exactly clear what I'm doing.
    – Chance
    Commented Apr 28, 2015 at 14:34
  • Indeed, gitextensions makes the list of stashes look like a branch; while this can help the beginners accommodate with git easier, it misleads them later. SourceTree presents the stashes as independent objects, the same way it shows the branches, the tags and the remotes. Give it a try (it's free), maybe you'll like it. It is also a Mercurial client.
    – axiac
    Commented Apr 28, 2015 at 14:51
  • "The list of stashes is stored as meta-data" - as far as I can see in the refs/logs/stash basically. What is git save you refer to ? Commented Jun 5, 2017 at 10:43
  • 1
    @Mr_and_Mrs_D it should have been git stash save, I forgot the stash when I wrote the answer. I fixed it now. Thank you for pointing it out.
    – axiac
    Commented Jun 5, 2017 at 11:07
5

Did you try Sourcetree: http://www.sourcetreeapp.com/

It might solve your problem.

1
  • 3
    SourceTree is a good Git GUI client but it cannot stash individual files. Maybe this is because the stash command was not designed to work this way?
    – axiac
    Commented Apr 15, 2015 at 8:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.