So if I have a Git repo on my local machine and I send it to a friend. He creates a branch (or maybe he doesn’t – I don’t think it’s too important), does some work and sends it back to me. Now I have two repos: mine, which I have also been working on; and his, with a new branch which he has been working on.
How do I get it all back together!?
How are you “sending it to a friend”? Git has built-in ways of sharing things, if you’re simply copying the repo you’re making this harder on yourself than it needs to be.
If you have a second copy of the repo from your friend on your local file system, and you want to merge from it, you can set it as a “remote”:
Now you have a remote named
other-repopointing at the copy of your repo, and you can fetch the changes your friend made, making your original repo aware of them:Now that your original repo knows about the branches in
other-repo, you can merge them in:Your master branch will now contain the changes your friend made in
other-repo‘s master branch.