我怎样才能从git中删除分离的提交?

时间:2013-12-18 18:40:21

标签: git github

我有两个独立的提交。我怎样才能将它们移除,就好像它们从未出现过一样? 我不想保存历史记录或其他日志。什么都没有。

2 个答案:

答案 0 :(得分:7)

你的意思是你有一个独立的头部时做出的提交?如果是这样,只需:

git checkout some_branch

您的提交将不会再显示在例如git log。当Git运行其垃圾收集扫描时,它们将在某些时候从存储中剔除。如果您想立即解决问题,请参阅此问题的答案: How to remove unreferenced blobs from my git repo

答案 1 :(得分:0)

对我来说,删除本地 master 分支很有效

<块引用>

git branch -D master

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

<块引用>

git checkout -b master

然后我 published 远程,由于某种原因,origin/master 和本地 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
相关问题