Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stash selected files with Git Extensions

Is there a way with Git Extensions to only stash some of the uncommitted files?

Say I have three files changed in the working dir (uncommitted) but I only want to stash 2 of them. FYI It doesn't seem to matter whether the uncommitted files are staged or not - when I use stash, they all get stashed.

like image 473
Cincinnati Joe Avatar asked Mar 05 '14 21:03

Cincinnati Joe


People also ask

How do I stash specific files?

The syntax of the command to stash specific files in Git is git stash push <file> . Thus, we do as follows to stash the changes done only to the file example. txt . Thus, we have stashed the changes only of the file example.

Does git stash include added files?

By default git ignores untracked files when doing stash. If those files need to be added to stash you can use -u options which tells git to include untracked files. Ignored files can be added as well if -a option is specified. -a will include both untracked and ignored files.

Can you stash multiple changes in git?

If you want to git stash pop twice because you want both stashes in the same commit but you encounter "error: Your local changes to the following files would be overwritten by merge:" on your 2nd git stash pop , then you can: 1) git stash pop , 2) git add . , and 3) git stash pop . This helped me.


2 Answers

In command line, you would:

  • add to the index the files you don't want to stash
  • do a git stash save --keep-index, as mention in this answer or this one.

Since issue 479 of GitExtensions, you should be able to do the same, since there should be a checkbox to the stash form which appends '--keep-index' to the 'stash save' command.

like image 192
VonC Avatar answered Sep 19 '22 01:09

VonC


Pretty old question, but in the latest version of GIT Extensions, the "Manage Stashes" window accessible from the Commands menu has 2 buttons.

  • Stash All Changes
  • Stash Selected Changes

The second one does the job. Pretty obvious in retrospect.

like image 43
Wade Hatler Avatar answered Sep 19 '22 01:09

Wade Hatler