从git仓库中删除无关的提交

时间:2019-05-24 00:34:28

标签: git

我有一个存储库,其中包含来自不同项目的一堆提交,并且不在当前项目的任何分支上。它们只是显示在彼此关联的历史记录中,而没有连接到项目中的任何分支。

因此,如果我执行git branch --contains <commit hash>,则不会返回任何内容。

(我相信这些是在对远程gitolite3存储库进行一些更改并在其状态错误时进行提取的时候到达的。)

我想从提交数据库中删除它们,因为它们根本不属于这里。

我该怎么做?

我在git prune之前和之后都尝试过git reflog expire --expire=now --expire-unreachable=now --all,但是并没有删除它们。我也尝试过git gc,但这也无济于事。

这似乎与Completely remove commit from git database有关,但是我在reflog或分支中找不到任何引用这些提交的内容,这会阻止修剪删除它们。我讨厌只需要删除数据库中的对象,这似乎是做事的一种坏方法。

1 个答案:

答案 0 :(得分:2)

导致$ /bin/python3.6 fastfileperformance.py fastfile_time 1.15%, python_time 0.87% Python timedifference 0:00:00.695292 FastFile timedifference 0:00:00.796305 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.13%, python_time 0.88% Python timedifference 0:00:00.708298 FastFile timedifference 0:00:00.803594 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.14%, python_time 0.88% Python timedifference 0:00:00.699614 FastFile timedifference 0:00:00.795259 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.15%, python_time 0.87% Python timedifference 0:00:00.699585 FastFile timedifference 0:00:00.802173 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.15%, python_time 0.87% Python timedifference 0:00:00.703085 FastFile timedifference 0:00:00.807528 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.17%, python_time 0.85% Python timedifference 0:00:00.677507 FastFile timedifference 0:00:00.794591 $ /bin/python3.6 fastfileperformance.py fastfile_time 1.20%, python_time 0.83% Python timedifference 0:00:00.670492 FastFile timedifference 0:00:00.804689 不删除提交的另一件事是,是否存在引用该提交或包含该提交的链的标签。

private fun getNearestPlaceList(placesClient: PlacesClient) {
        val placeFields = Arrays.asList(Place.Field.NAME)
        val request = FindCurrentPlaceRequest.builder(placeFields).build()
        placesClient.findCurrentPlace(request).addOnSuccessListener { response ->
            placeList.clear()
            for (placeLikelihood in response.placeLikelihoods) {
                if(!placeLikelihood.place.id.isNullOrEmpty() && !placeLikelihood.place.name.isNullOrEmpty()){
                    var placeModel = PlaceModel(placeName = placeLikelihood.place.name!!, placeId = placeLikelihood.place.id!!)
                    placeList.add(placeModel)
                }
            }
            setAdapter(placeList)
        }.addOnFailureListener { exception ->
            if (exception is ApiException) {
                Log.e(TAG, "Place not found: " + exception.statusCode)
            }
        }
    }

这是相关帖子s6的建议

相关问题