I want to push from git to multiple remote repositories

Asked 2 years ago, Updated 2 years ago, 42 views

I wanted to push it from git to multiple remote repositories, so I set up two URLs in the git config file as follows and pushed them.

The first one is pushed, but
The second one is not reflected and does not appear in the log (the log that appears after the push command).

 [ remote "origin" ]
        [email protected]:xxxx/xxxx.git
        [email protected]/yyyy/yyyy.git
        fetch=+refs/heads/* —refs/remotes/origin/*

When I replaced url and tested it, it was reflected on both sides, so I think the connection with ssh is going well, but I would appreciate it if you could let me know if there are any other points to check.

Sakura is a rental server in Sakura, and we are organizing the following site by referring to it.
https://tapioca-hiroyuki.net/?blog=git0320

Install a bare repository and get pushed there
Set hook and pull non-bear (directory for production publishing)
That's how it works.

If you run git push origin master, you will see the following log:

Counting objects—3, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 332 bytes | 0 bytes/s, done.
Total3(delta2), reused0(delta0)
remote:Resolving delta: 100% (2/2), completed with 2 local objects.
To [email protected]: xxxx/xxxx.git
   3452346es2..456h8b2 master->master
fatal —Unable to create '/var/www/html/xxx/.git/refs/remotes/origin/master.lock': ???

最後The last part of ?? was displayed as permission denied before the git version was upgraded

git

2022-09-30 10:27

1 Answers

If you execute the git remote-v command, will the output look like this?I think it was supposed to output two lines for the origin push.

origin [email protected]:xxxx/xxxx.git(fetch)
origin [email protected]: xxxx/xxxx.git(push)
origin [email protected]/yyyy/yyyy.git(push)

Adding the url attribute as described in the question statement can be done with the following command, and it certainly seems to work (v2.11.0)

 git remote add origin [email protected]:xxxx/xxxx.git
git remote set-url --add origin [email protected]/yyyy/yyyy.git

However, as far as the reference links and man below are concerned, it seemed more appropriate to set the pushurl attribute as follows:

 git remote add origin [email protected]:xxxx/xxxx.git
git remote set-url --add --push origin [email protected]:xxxx/xxxx.git
git remote set-url --add --push origin [email protected]/yyyy/yyyy.git

Note:

The <pushurl>is used for pushes only.It is optional and defaults to <url>.

From man of git-push. The url attribute value is the default value when pushurl is not present (so it feels strange to have multiple defaults...?).


2022-09-30 10:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.