Search code examples
gitsshgitolite

Git: How to merge two folder pointing to the same repository


I cloned a repository on a pc, and made some branches and commit. I was not able to push it (because of ssh authentication was not possible on pc). So I sent the file to another Pc (zip file), which could push the changes.

Folder1: contains the unziped files.

Folder2: contains a cloned version of the same repos, but without the changes in folder1.

I tried to push it but the server told me this error "fatal: The remote end hung up unexpectedly".

I changed the remote url using git config remote.origin.url=new_url to use the git protocol instead of the http. But even then, I am unable to push the changes.

So how can I either push my changes (from folder1) to the server, or merge the changes from folder1 to folder2, and be able to keep history?

thanks

Edit:

Based on @VonC's answer, I used these commands to merge correctly.

git bundle create bundle.bkp --all
git remote add temp-repos-to-merge ~/path/to/bundle.bkp
git fetch temp-repos-to-merge
git merge --no-ff temp-repos-to-merge/path/to/specific-branch

Solution

  • Rather than a zip, I would bundle folder1 repo (see "How to backup git server?"), which produces also one file.

    Then I would go to folder2 and pull from that bundle (after having added it as a remote)

    See "How to use git-bundle for keeping development in sync" for a concrete example.