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.

  • Git - move branch to master
  • Master out of sync with remote with stashed files (one user only)
  • How get local root path in svn?
  • Is there a way to easily convert a series of tarballs of a source tree into a git repository?
  • github: PGP key usage flags do not allow signing
  • How to push an existing projects in new Github repository?
  • 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?



    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

  • How to get Jenkins to connect to git repository
  • Merge two Git repositories imported through git-tfs
  • git add only some changed files
  • How to make docker-compose load the context from GIT to a specific directory?
  • merge deletes and adds wrong files
  • How can I make git do the “did you mean” suggestion?
  • One Solution collect form web for “Git: How to merge two folder pointing to the same repository”

    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.

    Git Baby is a git and github fan, let's start git clone.