Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply only some of a git stash?

Tags:

git

I want to apply some of the changes in a git stash to one commit, and the rest of the changes to another.

like image 301
Rose Perrone Avatar asked Mar 04 '13 23:03

Rose Perrone


People also ask

How do I apply a specific stash change in git?

You can reapply stashed changes with the commands git stash apply and git stash pop . Both commands reapply the changes stashed in the latest stash (that is, stash@{0} ). A stash reapplies the changes while pop removes the changes from the stash and reapplies them to the working copy.

How do I remove a single file from a git stash?

Here's what I did to solve the issue: git restore --staged path/to/file. git reset HEAD -- path/to/file to remove the file from the staging area.

Can you git stash apply multiple times?

If you made two stashes, then just call git stash pop twice. As opposed to git stash apply , pop applies and removes the latest stash. You can also reference a specific stash, e.g.

How do I grab a git stash?

To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.


1 Answers

git checkout stash@{0} -- <filename> 

You can also do this with a list or a glob of filenames.

like image 181
Leo Avatar answered Oct 07 '22 18:10

Leo