one repo cloned in two places on git bash

Viewed 21

i mistakenly cloned a repo in two different folders on git bash one is located on the root folder while the other is in a folder I created, now all my recent commits and push doesn't show up on the one on the root folder even though both of them are the same, now i want to merge both together to become one repo and be on the root folder

1 Answers

You can add a remote to reference your second local repository from your first:

cd /path/to/root/folder
git remote add secondrepo /path/to/subfolder
git fetch secondrepo
git switch main
git merge secondrepo/main

This assumes you were committing on branch main in both repositories.

Related