Ciasto piekarz
Ciasto piekarz

Reputation: 8277

git stash but keep whats being stash instead of reverting to last commited change

So when I git stash it will pack my changes since the last commit to a list, however is their any way that I do not have to commit, but still stash and keep the uncommitted changes or of their is any other git command for that ?

Upvotes: 0

Views: 657

Answers (2)

Jonathan.Brink
Jonathan.Brink

Reputation: 25443

If you have changes that you would like to keep around but not have to keep in your stash stack perhaps you could store them on a separate topic branch.

So, the procedure would be:

# do some work
# realize you want to go in another direction but keep your changes somewhere
git checkout -b topicName
git add .
git commit -m "useful description"
git checkout - # go back to previous branch

Then, whenever you want you can either merge or cherry-pick the "stashed" away changes on that topic branch back on to the branch you are working on.

git merge topicName

Upvotes: 0

Cristiano Araujo
Cristiano Araujo

Reputation: 1972

You with a single command you can't. But you can stash the changes and then apply they back, keeping them into the stash. Check the stash docs for more info.

git stash
git stash apply

If you want, you can create a alias in your .gitconfig file. You can check how to create alias here.

[alias]
stash-save = !git stash && git stash apply

Upvotes: 3

Related Questions