Skip to content

Instantly share code, notes, and snippets.

@hthuwal
Last active August 30, 2018 16:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hthuwal/6a44b1439013141a82204a323b282577 to your computer and use it in GitHub Desktop.
Save hthuwal/6a44b1439013141a82204a323b282577 to your computer and use it in GitHub Desktop.
Git Tricks

Suppose you wanna merge repoA and repoB with no common history

  1. cd into repoA
  2. Add repoB as remote
    git remote add repoB <repoB url>
  3. Fetch repoB's content
    git fetch repoB

Alternatively 2 & 3 can be done together as
git remote add -f repoB <repoB url #Add repoB as remote and fetch its contents

  1. Merge
    git merge --allow-unrelated-histories repoB
    Remove merge conflicts (if any) then commit

  2. Optional: Remove remote to repoB
    git remote remove repoB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment