Andrew Hundt
Andrew Hundt

Reputation: 2591

git parent tree accidentally pushed into subtree

I split one repository into 3, a tracking repository with git subtree, and two repositories I was splitting into modules. Somehow I managed to push the version with the subtrees on to one of the children repositories, which messed up the structure.

Here they are for reference:

How can I restore the repositories?

Upvotes: 2

Views: 186

Answers (1)

Andrew Hundt
Andrew Hundt

Reputation: 2591

First, make a backup since you will be nuking history.

In the local child1 repository, determine the hash of a version before the problem started, then blow away all of history up to that point:

cd path/to/separate/broken/child1
git reset --hard 7b202bfc915042c714aeca9516daf67d81c36b61

force push those changes to the remote

git push --force

The issues since the switch should now be gone. Switch to the parent, and then push the changes correctly

cd path/to/parent1
git subtree push --prefix path/to/child1/in/parent remotechildname master

The problem should then be solved

Upvotes: 1

Related Questions