Windows git https way how to achieve simultaneous push to multiple repositories, and according to each repository set a separate submission username
[remote "github"]
url = https://github.com/jock/test
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "gitlab"]
url = https://gitlab.com/test
fetch = +refs/heads/*:refs/remotes/origin/*|
How do I set up the respective commit user names for github gitlab
github :github-username
gitlab: gilab-username
3
if you need to change only the alias, try these steps. I tried different versions a few years ago, hope that works.
- Set-Up Multiple Remotes (Possible, you have already these)
[remote "github"]
url = https://github.com/jock/test
fetch = +refs/heads/*:refs/remotes/github/*
[remote "gitlab"]
url = https://gitlab.com/test
fetch = +refs/heads/*:refs/remotes/gitlab/*
- Create a file in the “.git/hooks” directory of your repository
touch .git/hooks/pre-push
chmod +x .git/hooks/pre-push
- a. Edit file like the following
#!/bin/sh
remote="$1"
if [ "$remote" = "github" ]; then
git config user.name "github-username"
git config user.email "[email protected]"
elif [ "$remote" = "gitlab" ]; then
git config user.name "gitlab-username"
git config user.email "[email protected]"
fi
- b. Push each remote
git push github
git push gitlab
- Additionally, automate the pushing of all remotes in the git folder
[alias]
multipush = "!f() { git push github && git push gitlab; }; f"
- Use it
git multipush
2