Windows git https方式如何实现同时推送到多个仓库,并根据每个仓库设置单独的提交用户名
[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/*|
如何为github gitlab设置各自的提交用户名
github :github-username
gitlab: gilab-username
如果您只需要更改别名,请尝试以下步骤。几年前我尝试过不同的版本,希望有效。
[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/*
touch .git/hooks/pre-push
chmod +x .git/hooks/pre-push
#!/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
git push github
git push gitlab
[alias]
multipush = "!f() { git push github && git push gitlab; }; f"
git multipush