git-stash


How would I extract a single file (or changes to a file) from a git stash?

On the git stash manpage you can read (in the "Discussion" section, just after "Options" description) that: A stash is represented as a commit whose tree records the state of the working directory,... Read More


Is git stash branch-specific or for the whole repository?

No and No. git stash is per-repository. Here is a nice page on how to use it.... Read More


Undoing accidental git stash pop

Try using How to recover a dropped stash in Git? to find the stash you popped. I think there are always two commits for a stash, since it preserves the index and the working copy (so often the index... Read More


Why does git stash pop say that it could not restore untracked files from stash entry?

I managed to recreate your issue. It seems if you stash untracked files and then you create those files (in your example, foo.txt and bar.txt), then you have local changes to untracked files that wou... Read More


Can "git pull" automatically stash and pop pending changes?

For Git 2.6+ (released 28 Sept 2015) The ~~only~~ git config setting which would be of interest is: rebase.autoStash (with Git 2.27, Q2 2020, you now also have merge.autostash , see below) When set... Read More


How can I git stash a specific file?

EDIT: Since git 2.13, there is a command to save a specific path to the stash: git stash push <path>. For example: git stash push -m welcome_cart app/views/cart/welcome.thtml OLD ANSWER: You can do... Read More


Why does `git stash -p` sometimes fail?

This happens for me any time I try to split a hunk into smaller hunks that are too close together (less than 3 lines between changes). The short explanation is that the patch has context lines in it... Read More


git stash - Git: Create a branch from unstaged/uncommitted changes on master

No need to stash. git checkout -b new_branch_name does not touch your local changes. It just creates the branch from the current HEAD and sets the HEAD there. So I guess that's what you want. --- Ed... Read More


git - How to unstash only certain files?

As mentioned below, and detailed in "How would I extract a single file (or changes to a file) from a git stash?", you can apply use git checkout or git show to restore a specific file. git checkout s... Read More


Git stash: "Cannot apply to a dirty working tree, please stage your changes"

When I have to apply stashed changes to a dirty working copy, e.g. pop more than one changeset from the stash, I use the following: $ git stash show -p | git apply -3 && git stash drop Basically it... Read More