Delete stash gitkraken11/14/2023 ![]() ![]() It is however possible to create a commit that duplicates everything from the original stash commit but changes its message.įind the hashes for the stash commit's tree and parents: $ git show -s -pretty=raw f2adfc7bbebe852693ad8f6ac889e4923230c872 The git stash store-method described in qzb's answer only updates the stash message in one of two places, causing many git frontends to still show the old message. changed.Īs you also can see, refs/stash has a changed SHA, too. This is due to how stashes are handled (parents are included of the SHA, and stashes have their stashes as parent). If you look carefully, you will see, that several commits have changed SHA. | | * 246dc5c untracked files on master: 8bdcc32 DĪs you can see, still is shown as 2fbf900 (refs/stash) WIP on master: 8bdcc32 D in git log. 2fbf900 (refs/stash) WIP on master: 8bdcc32 D Now without changing commit (note: the SHA in following will be different at your side): git stash drop stash store -m. * b1852c6 WIP on master: 8bdcc32 WIP on master: 8bdcc32 D | | * 4d62f52 untracked files on master: 8bdcc32 D e0e281b (refs/stash) WIP on master: 8bdcc32 D Git log -oneline -graph -decorate -all git stash list Example git init scratchįor a in A B C D do date >$a git add $a git commit -m $a doneįor a in X Y do echo $a > Z git stash save -all done There are ways to do this without switching branches, but this is beyond the scope of this answer. It renumbers the stashes, so the changed stash becomes need to enter the $MESSAGE twice or use some environment variable (in the example: MESSAGE) So this recipe can only be applied when git status -porcelain is clean (read: does not output anything) ![]() Switch back (which assumes you came from "master") and cleanup.Store the stash, based on the qzb's answer.Use git commit -amend to replace the commit message, this changing the SHA of the "stash in question".This is safe, as we still have this on the branch. Create a new (not yet existing) "scratch" branch from the "stash in question" and switch to it.Hence the solution is: git checkout -b scratch stash drop commit -amend -m "$MESSAGE" ![]() To be able to do git commit -amend you need to be on the TIP of a branch. There might be a better way to do it, but this recipe here is easy to understand, I hope. If you not only want to correct the stash message and also want to correct the commit message of the stash, such that git stash listīoth agree to what is shown, you need a bit more. I need my history to only show the commit where HEAD is currently at, and commits ahead of that to be gone from sight.Unless you do it manually or contribute an improvement to Git, you can use an alias: git config -global alias.stash-rename '!_() _'įor the benefit of the reader, here is an extension to the currently accepted and correct answer. Please help! My OCD is preventing me to ignore it and continue to do work and keep adding commits. I tried to wipe the local repo because thought it was simply a local thing- on Pantheon's DEV environment they are gone after the force push. ![]() I can't see them in terminal with git log but I like to use GitKraken to visually see my git history, and there they appear all the time. Fast forward, when I cloned the repo again, I can still see the commits that I thought I had erased from history. Later I did a hard reset to a certain commit and forced pushed to origin. I pushed commits to Pantheon's DEV environment, deployed on both TEST and LIVE environments. I need to get rid of commits that I have already reseted and force pushed to origin they keep coming up whenever I pull or clone the remote repo. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |