如何从 git 中删除分离的提交



我有两个分离的提交。我怎样才能像从未有过一样删除它们?我不想保存历史记录或其他日志。无。

你的意思是当你有一个分离的 HEAD 时所做的提交吗? 如果是这样,只需:

git checkout some_branch

您的提交将不再可见,例如 git log . 它们将在某个时候从存储中剔除,而 Git 运行其垃圾收集扫描。 如果现在想要剔除内容,请参阅此问题的答案:如何从我的 git 存储库中删除未引用的 blob

对我来说,

它的工作原理是删除本地master分支

git 分支 -D 主

那么我需要在移动到正确的点/提交后重新创建它

git 结帐 -b 大师

然后我published远程,由于某种原因,源/主和本地主之间的轨道仍然存在,我在远程存储库上发现只有一个干净的提交。

只是为了给出一个想法,这是我的起点:

* 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

最新更新