Fixing Git History After Retrieving The Wrong Repo

I made a mistake installing the remote on my git repository and extracted from a completely different project.

Fortunately, there was no merge, but now I have a history of 2 projects floating in my repo, and I'm trying to figure out how to return my repo to the state it was in before I made a wrong selection.

I read about the reflog, rebase, gcand other teams, trying to figure out what will help me get rid of the things that I accidentally pulled out, but still they were not.

It looks like I have a history of both projects in my repo, but they are completely independent. There are essentially two separate commit trees running parallel to each other, in fact this is what I see gitkwhen viewing all the branches:

enter image description here

You can see that commits in the middle are not related to commits at the beginning and end of the story. By date, they alternate, but gitkfor some reason does not show their alternation.

Isolated commits (in the middle of the figure) are the ones I'm trying to get rid of, and they don't seem to be tied to any industry. There is no way from any of my repo's HEADs to this set of commits.

So far I have tried (in order, if that matters):

git remote prune
git prune
git gc
git gc --aggressive --prune=tomorrow
git remote update --prune
git fetch --all

But so far nothing has helped. Can anyone suggest how can I remove these commits from my repo?

+5
source share
1 answer

You just need to remove the dangling tag ( 0.1.somethingwhere it somethingdoesn't appear on your screenshot) with git tag -d 0.1.something. Once this is done, the commits will be gc-able.

, , , , "", , , (, , refs,...)

+8

All Articles