简体   繁体   English

如何使用 git 重置来编辑旧提交

[英]How can I use git reset for editing old commits

1) Is there a way to edit or squash commits without using the Interactive mode of git rebase? 1) 有没有办法在不使用 git rebase 的交互模式的情况下编辑或压缩提交? 2) How do git reset --keep and git reset --merge work and how do they differ? 2) git reset --keepgit reset --merge如何工作,它们有何不同? I have read the git book, but I do not understand it yet...我看过git这本书,但是我还没有看懂……

You can do你可以做

git reset --soft <commit>
git commit -m "squashed"

to squash all commits between your current HEAD and <commit> .压缩当前HEAD<commit>之间的所有提交。

The git reset part undos all commits that came after <commit> but will keep the changes staged (you can check this with git status ). git reset部分撤消了<commit>之后的所有提交,但将保持更改暂存(您可以使用git status进行检查)。 The subsequent git commit will commit all those staged changes as a single commit.随后的git commit会将所有这些分阶段的更改作为单个提交提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何删除几个旧的提交,但保持所有其他提交在git中保持不变? - How can I strip several old commits but keep all the other commits unchanged in a git? 我在使用git reset时丢失了一些提交 - I lost some commits when I use git reset 如何在我的 GitHub 拉取请求中“git reset”到旧提交并添加更改而不删除旧提交 - How to "git reset" to an old commit and add changes WITHOUT deleting the old commits in my GitHub pull request 如何使用 Git 查看文件在哪些提交中被重命名? - How can I use Git to see in which commits a file was renamed? 如何将旧提交部署到 Heroku - How can I deploy old commits to Heroku 我可以恢复到旧的 Git 提交,同时保留最新的提交吗? - Can I revert to an old Git commit, while preserving the latest commits? git:如何将旧版本的提交应用于新版本的源代码 - git:How can I apply commits from old version on a new version of source-code git:检出旧的提交后,如何查看下一个提交? - git: after checking out an old commit, how can i see the next commits? 我该怎么做`git reset --soft <some-commit> `绕过合并合并提交? - How can I to do `git reset --soft <some-commit>` bypassing commits with merge? 如何在保持git不变的文件的同时重置提交? - How can I reset my commits while keeping my assume-unchanged files in git?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM