在过去的一个小时里,我改变了几件事,并一步步提交它们,但我刚刚意识到我忘记在一些提交之前添加更改的文件。
日志看起来像这样:
GIT TidyUpRequests u:1 d:0> git log
commit fc6734b6351f6c36a587dba6dbd9d5efa30c09ce
Author: David Klein <>
Date: Tue Apr 27 09:43:55 2010 +0200
The Main program now tests both Webservices at once
commit 8a2c6014c2b035e37aebd310a6393a1ecb39f463
Author: David Klein <>
Date: Tue Apr 27 09:43:27 2010 +0200
ISBNDBQueryHandler now uses the XPath functions from XPath.fs too
commit 06a504e277fd98d97eed4dad22dfa5933d81451f
Author: David Klein <>
Date: Tue Apr 27 09:30:34 2010 +0200
AmazonQueryHandler now uses the XPath Helper functions defined in XPath.fs
commit a0865e28be35a3011d0b6091819ec32922dd2dd8 <--- changed file should go here
Author: David Klein <>
Date: Tue Apr 27 09:29:53 2010 +0200
Factored out some common XPath Operations
有任何想法吗?
Use git rebase http://git-scm.com/docs/git-rebase。具体来说:
- Use
git stash
存储您要添加的更改。
- Use
git rebase -i HEAD~10
(或者无论您想看到多少提交)。
- 标记有问题的提交(
a0865...
) 通过更改单词进行编辑pick
在行的开头进入edit
。不要删除其他行,因为这会删除提交。[^vimnote]
- 保存变基文件,git 将返回到 shell 并等待您修复该提交。
- 使用以下命令弹出存储库
git stash pop
.
- 添加您的文件
git add <file>
.
- 修改提交
git commit --amend --no-edit
.
- Do a
git rebase --continue
这将根据新的提交重写您的其余提交。
- 如果您已标记多个提交进行编辑,请从步骤 2 开始重复。
- 如果您之前已将修改后的提交推送到其他任何地方,那么您将必须推送
--force
再次在遥控器上更新它们。然而,关于使用的常见警告--force
申请,如果你不小心并事先与他们协调,你很容易失去别人的工作。
[^vimnote]: If you are using vim
then you will have to hit the Insert key to edit, then Esc and type in :wq
to save the file, quit the editor, and apply the changes. Alternatively, you can configure a user-friendly git commit editor https://stackoverflow.com/questions/2596805/how-do-i-make-git-use-the-editor-of-my-choice-for-commits with git config --global core.editor "nano"
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)