我有两个独立的提交。如何将它们删除,就像它们从未存在过一样? 我不希望保存历史记录或其他日志。什么都不要。
您是指在分离头状态下进行的提交吗?如果是,只需执行以下操作:
git checkout some_branch
您提交的更改将不再在例如 git log
中可见。它们将在 Git 运行垃圾收集扫描时从存储中删除。 如果您想立即清除内容,请参阅此问题的答案:如何从我的Git仓库中删除未引用的Blob。
git gc
不够积极。回答已更新。 - Oliver Charlesworthgit version 2.18.0
。在处于分离的提交状态下创建了一个存储,之后摆脱了它,导致分离的提交立即消失。 - Cryptor对我而言,删除本地的master
分支并重新创建是可行的:
git branch -D master
然后在到达正确的节点/提交之后需要重新创建它:
git checkout -b master
接着我将其push
到远程,不知何故,本地的master和origin/master之间的联系仍然存在,但我发现在远端repo上只有一个干净的提交。
只是为了让你们明白,这是我的起点:
* 08c6d59 (tmp) add MStatus to key to compare. rif. #1858
| * 1f78459 (master) Merge branch 'master' of ssh://xxxxxxxxx:10022/xWave/csv_import_tool
| |\
| |/
|/|
| * d190a9f field_mapping replace field_map. rif. #1725
| | * 3e2a843 (quickfix-1858) is_the_same_as_dbrow false if import has repricing update. rif. #1858
| |/
|/|
* | 5e3a9b8 (HEAD, origin/master) field_mapping replace field_map. rif. #1725
|/
* 7b4a700 field map to aufbau+platform attributes. rif. #1725
* 4a174f7 set timeout of 12 seconds, then exits parse_csv_lines. rif. #1836
* b73df93 json encode error message in all cases. rif. #1836
* 8d80459 include platform attribute to map of fields. rif. #1801 step 1
* 331244f add mstatus and quantity options. rif. #1698 #1675
* 4dd3c48 move in unused the unused files
* 3326ff5 change the right file
变更后:
* 08c6d59 (HEAD -> master, origin/master, tmp) add MStatus to key to compare. rif. #1858
| * 3e2a843 (quickfix-1858) is_the_same_as_dbrow false if import has repricing update. rif. #1858
|/
* 5e3a9b8 field_mapping replace field_map. rif. #1725
* 7b4a700 field map to aufbau+platform attributes. rif. #1725
* 4a174f7 set timeout of 12 seconds, then exits parse_csv_lines. rif. #1836
引用日志
08c6d59 (HEAD -> master, origin/master, tmp) HEAD@{0}: checkout: moving from 08c6d59c0d8e9a8ea58c850f092f1a8800857574 to master
08c6d59 (HEAD -> master, origin/master, tmp) HEAD@{1}: merge tmp: Fast-forward
5e3a9b8 HEAD@{2}: checkout: moving from tmp to origin/master
08c6d59 (HEAD -> master, origin/master, tmp) HEAD@{3}: commit: add MStatus to key to compare. rif. #1858
5e3a9b8 HEAD@{4}: checkout: moving from master to tmp
1f78459 HEAD@{5}: checkout: moving from 5e3a9b893a31674610d52e505830f94c4e96409e to master
5e3a9b8 HEAD@{6}: checkout: moving from master to 5e3a9b8
1f78459 HEAD@{7}: pull origin master: Merge made by the 'recursive' strategy.
d190a9f HEAD@{8}: commit: field_mapping replace field_map. rif. #1725
7b4a700 HEAD@{9}: reset: moving to HEAD~
5e3a9b8 HEAD@{10}: checkout: moving from quickfix-1858 to master
3e2a843 (quickfix-1858) HEAD@{11}: commit: is_the_same_as_dbrow false if import has repricing update. rif. #1858