How to Configure Git to Push to Multiple Remotes

You might have seen the news today that GitHub is planning on implementing community guidelines, and wanted to branch out. I personally don't think anything I make will ever fall into "hateful speech", but you can never be too safe.

Anyway, now to the meat. How to do it!
First off, choose where you're going to have mirrors. I chose GitLab and BitBucket. Both of these have import functions. First thing you should do is import all your repositories.
Next, we're going to set up SSH keys. I did this on Windows, but all of this is the same on any platform. Probably just follow your service's guide to generating ssh keys, except as you are using multiple, make sure to set the key location to something that's not default. I had mine set to 'id_github', 'id_gitlab' and 'id_atlassian'. Add these keys to the services. (Ignore the bit in the GitHub about adding it to the agent, we do that later.)

Next we set up ssh to use these keys properly. In your ssh config (~/.ssh/config), add these lines (Replacing the location of your identity file):

Host github
	User git
	IdentityFile ~/.ssh/id_github

Host gitlab
	User git
	IdentityFile ~/.ssh/id_gitlab

Host bitbucket
	User git
	IdentityFile ~/.ssh/id_atlassian

Now for the tedious bit. Adding these as alternate clone loactions. First off, you have to find where all the git repos on your disk are. Luckily, all mine were in a single folder.
Then, you open your terminal in their folder. I'm going to assume that you only have one push location at this point, being github. To verify, you can run 'git remote -v', and you should get this:

origin somethingsomething.git (fetch)
origin somethingsomething.git (push)

If that's what it looks like, great! Go ahead and continue.
This is what you'll have to run for each repo:

# Removes current origin
$ git remote rm origin 
# Adds github as pull origin
$ git remote add origin git@github:user/repo.git
# Adds github as a push target
$ git remote set-url --add --push origin git@github:user/repo.git 
# Adds gitlab as a push target
$ git remote set-url --add --push origin git@gitlab:user/repo.git 
# Adds bitbucket as a push target
$ git remote set-url --add --push origin git@bitbucket:user/repo.git
# Pushes your repository to all 3 and sets origin as upstream
$ git push --set-upstream origin master
# Note: SSH might want you to verify that the remotes are correct.
# Note: You can hit yes for all of them, provided you trust them.

That's it! Maybe consider adding some features of the new git push target you just added. I quite like GitLab CI.
You can go ahead and test the implementation by adding some code and doing a 'git push -v'.

Edit: I have written a short PowerShell function if you want to script the addition of these remotes, simply add in your github and run the function like so:

# This is the declaration of the function, perhaps add it to your $PROFILE if you plan to use it frequently.
function Setup-Git-Remotes {
    $githubname = "tf2manu994"
    $gitlabname = "tf2manu994"
    $atlassianname = "tf2manu994"
    $reponame = $args
    git remote rm origin
    git remote add origin git@${githubname}/${reponame}.git
    git remote set-url --add --push origin git@github:${githubname}/${reponame}.git
    git remote set-url --add --push origin git@gitlab:${gitlabname}/${reponame}.git
    git remote set-url --add --push origin git@bitbucket:${atlassianname}/${reponame}.git
# This is an example of how you would invoke it:
Setup-Git-Remotes dotfiles
# This would set up the remotes for pushing to yourname/dotfiles. 
# Configure your username in the top 3 lines of the function.

Edit: It has been brought to my attention that GitLab lets you do this natively. Oops.

I used a fair few sources for this, but I was implementing this myself and didn't think of writing a post for it. I'll try look through history and find them.
git-scm book
GitHub and GitLab's ssh key guide
I'm sure I missed some, but this is about all I can get.