Answer a question

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

Answers

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.

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐