gpt4 book ai didi

git - 我如何进行交互式 git 修改?

转载 作者:行者123 更新时间:2023-12-02 01:31:44 29 4
gpt4 key购买 nike

在使用交互式补丁模式选择哪些部分时,如何撤消上次提交的部分内容?当您在上次提交中不小心检查了太多行时,这会很有用,例如调试您的编辑器为您所做的打印语句或空格更改。

天真的做法是

git commit --amend --interactive --patch

但这似乎行不通。也就是说,它只会让您进入编辑器进行改写。

丑陋的做法是

git show HEAD~1:path/to/some/file > path/to-some/file
git add -up
git commit --amend

但这很烦人,因为它让你事先指定文件,并让你一个一个地重新添加所有补丁(而不是让你只取消添加一些零碎的东西)

最佳答案

怎么样

git reset -p HEAD~
git commit --amend --no-edit

第一个命令将允许您以交互方式取消暂存 block (选择 y 作为您想要从提交中退出的部分),然后提交修改会将其写入新的提交。

关于git - 我如何进行交互式 git 修改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73154985/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com