git stash and apply

Quick “TL;DR” take-away version, so one can come back later and study more git stash hangs a stash-bag—this is a peculiar form of a merge commit that is not on any branch—on the current HEAD commit. A later git stash apply, when you’re at any commit—probably a different commit—then tries to restore the changes git … 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 that using git stash –patch (or git stash -p) — you’ll enter interactive mode where you’ll be presented with each hunk that … Read more

How do you stash an untracked file?

To stash your working directory including untracked files (especially those that are in the .gitignore) then you probably want to use this cmd: git stash –include-untracked Alternatively, you can use the shorthand -u instead of –include-untracked, or simply git stash –all which stashes all files, including untracked and ignored files. This bahaviour changed in 2018, … Read more

How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?

If you want remove all local changes – including files that are untracked by git – from your working copy, simply stash them: git stash push –include-untracked If you don’t need them anymore, you now can drop that stash: git stash drop If you don’t want to stash changes that you already staged – e.g. … Read more