How do I commit to multiple repositories at the same time, with separate commit usernames based on each repository setting

  Kiến thức lập trình

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.

  1. 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/*
  1. 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
  1. Additionally, automate the pushing of all remotes in the git folder
    [alias]
        multipush = "!f() { git push github && git push gitlab; }; f"
  1. Use it
    git multipush

2

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT