簡體   English   中英

如何將提交還原到特定文件夾?

[英]How to revert a commit but to a specific folder?

我已經做出了這樣的承諾

提交 hash - hash1 -> 更改 = a/1.txt, a/2.txt, b/1.txt

現在我正在通過git revert -m 1 hash1恢復此提交,但我只想刪除對文件夾a/所做的更改,但想保留b/中的更改

可能嗎?

git revert -m 1 hash1
# If needed, resolve conflicts and commit;
# those outside of a/ may be resolved arbitrarily.
git reset --hard HEAD^
git checkout hash1 a/
git commit -C HEAD@{1}

您也可以使用revert -n然后在提交之前重置所有其他目錄; 只有當有許多這樣的其他目錄時,上面的配方才更可取,因為它只命名a .

您可以使用--no-commit

git revert --no-commit <commit_id>
git restore --staged b/
git checkout .
git commit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM