How can I create a GIT Stash from a Commit?

etoxin

I would like to create a new GIT stash from a commit on a branch. Is this even possible?

Uzbekjon

But why? If you have a commit, it means you already have those changes applied to your files. Some, files might have been changed since the commit, but then, if you try to get a stash of that commit changes, then the stash would be the diff of your current files and the state of these files at the commit. What I am trying to say is that I can't think of a case when you would need that.

But anyway, you can get the changes of the commit, create a diff, apply it and then stash whatever was the difference.

git diff YOUR-COMMIT^ YOUR-COMMIT > stash.diff
git apply stash.diff
git commit .
git stash

You don't have to create a temporary stash.diff file. You can simply pipe git diffs output to git apply.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I create a GIT Stash from a Commit?

From Java

How do I resolve git saying "Commit your changes or stash them before you can merge"?

From Java

How can I undo my last commit in Git and stash those changes instead?

From Java

How can I rename a git stash?

From Java

How can I git stash a specific file?

From Dev

How can I share a git stash?

From Dev

How can I create a commit with a new SHA in git?

From Java

How do I create a new Git branch from an old commit?

From Java

How to delete a stash created with git stash create?

From Dev

How can I stop myself from using 'git commit -a'?

From Dev

How can I extract Git commit hash from VS/msbuild?

From Dev

How to list the parent commit of a stash in `git stash list`

From Dev

How can I create a bash or zsh alias for git commit, git pull, git push and pull on a remote server?

From Dev

How can I checkout an untracked file in a git stash?

From Dev

Git Error: stash or commit

From Dev

How can I create bare repositories in atlassion-stash

From Dev

How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests?

From Dev

How can I revert back to a Git commit?

From Dev

Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

From Dev

Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

From Java

How can I run `git commit` and `git push` in atom?

From Dev

How can I define an alias for a Git subcommand (e.g. for `list` in `git stash list`)?

From Dev

Using git diff, how can I show the patch from the index to a given commit?

From Dev

How can I use keyboard shortcuts to do a git commit and push from IntelliJ IDEA?

From Dev

How can I tell what happened in a Git commit with two parents that did not merge in the changes from the second parent?

From Dev

How can I take lines from someone's code via Git so that they are credited in commit history?

From Dev

How can I launch vim from my program and capture the written output, like Git commit

From Dev

How can I make a single commit of specific branch from other pushed commits in Git?

From Dev

How can I generate a Composer author list from Git's commit history?

Related Related

  1. 1

    How can I create a GIT Stash from a Commit?

  2. 2

    How do I resolve git saying "Commit your changes or stash them before you can merge"?

  3. 3

    How can I undo my last commit in Git and stash those changes instead?

  4. 4

    How can I rename a git stash?

  5. 5

    How can I git stash a specific file?

  6. 6

    How can I share a git stash?

  7. 7

    How can I create a commit with a new SHA in git?

  8. 8

    How do I create a new Git branch from an old commit?

  9. 9

    How to delete a stash created with git stash create?

  10. 10

    How can I stop myself from using 'git commit -a'?

  11. 11

    How can I extract Git commit hash from VS/msbuild?

  12. 12

    How to list the parent commit of a stash in `git stash list`

  13. 13

    How can I create a bash or zsh alias for git commit, git pull, git push and pull on a remote server?

  14. 14

    How can I checkout an untracked file in a git stash?

  15. 15

    Git Error: stash or commit

  16. 16

    How can I create bare repositories in atlassion-stash

  17. 17

    How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests?

  18. 18

    How can I revert back to a Git commit?

  19. 19

    Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

  20. 20

    Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

  21. 21

    How can I run `git commit` and `git push` in atom?

  22. 22

    How can I define an alias for a Git subcommand (e.g. for `list` in `git stash list`)?

  23. 23

    Using git diff, how can I show the patch from the index to a given commit?

  24. 24

    How can I use keyboard shortcuts to do a git commit and push from IntelliJ IDEA?

  25. 25

    How can I tell what happened in a Git commit with two parents that did not merge in the changes from the second parent?

  26. 26

    How can I take lines from someone's code via Git so that they are credited in commit history?

  27. 27

    How can I launch vim from my program and capture the written output, like Git commit

  28. 28

    How can I make a single commit of specific branch from other pushed commits in Git?

  29. 29

    How can I generate a Composer author list from Git's commit history?

HotTag

Archive