我有两次存储,我需要在一次提交中提交两次存储。
我使用git stash apply
来应用最新的存储,但是当我再次使用它时,它会抛出以下错误,
error: Your local changes to the following files would be overwritten by merge: library/HQ/groupsql.sql Please commit your changes or stash them before you merge. Aborting The stash entry is kept in case you need it again.
如何 pop 两个存储然后提交它们。
最佳答案
我认为你可以执行以下操作:
// to see the list of "stashes" (like every time when stash run 'git stash' a new entry is created in the list
> git stash list
// Lest assume you need stash@{1} and stash@{3} for the sake of example
> git stash apply stash@{1}
git commit -am "Whatever message"
> git stash apply stash@{3}
git commit --amend // to add changes from stash3 from the previous commit
底线,每个存储应用一旦完成就会在本地分支上生成提交,但只要更改是本地的(而不是推送),您就可以更改历史记录
我建议您也阅读This thread ,它包含一些巧妙的技巧,自 git 2.11 起可用:你可以使用 git stash apply n
而不是git stash apply stash@{n}
另一个建议:您可以使用 git stash show stash@{3}
查看 stash 3 中更改了哪些文件(如果您不确定要应用哪个 stash)
不过,我从未见过在一个命令中执行此操作的功能。所以现在我的答案是“不,你不能一次应用多个存储”。我很高兴能得到更有经验的 git 用户的证明。
关于git 一次应用多个存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58926699/