开发者

How can I have it to where "git push" pushes to local repositories?

开发者 https://www.devze.com 2023-02-04 14:59 出处:网络
I can do git remote add origin x@x:~/blah and git push will work. But if 开发者_StackOverflow中文版I create a local copy git clone ~/blah inside /var, then git remote add local /var/blah inside ~/blah

I can do git remote add origin x@x:~/blah and git push will work. But if 开发者_StackOverflow中文版I create a local copy git clone ~/blah inside /var, then git remote add local /var/blah inside ~/blah, when I try git push it doesn't push the updates.

How can I make git push updates to local copies?

I have a shared library I use in a bunch of projects. I use git clone inside other folders to get a local copy of the library. When I update the main library I have to go to each local copy and type git pull to get the updates? How can I say git push to push code to all libraries?


By default, git push pushes to origin. If you want to push to a different remote repository (on the same machine or otherwise), you need to do git push <remote-name>. Also keep in mind what mipadi says about non-bare repositories.

So in your case, after a git remote add local /var/blah, you would do git push local to push changes to the repo in /var/blah.

A little google-fu came up with this post for pushing to multiple remote repositories at once:

http://web.archive.org/web/20110828185858/http://jeetworks.com/node/22

Essentially, a remote can have multiple urls. To do this edit your .git/config and put something like this:

[remote "all"]
    url = /some/path/to/repo1
    url = /some/path/to/repo2

After that, you can do git push all to push to both of the remote urls pointed to by the remote "all".


Are you pushing to a non-bare repository? If you are, the repo itself will be updated, but the checked-out (on-disk) files will not be updated.

0

精彩评论

暂无评论...
验证码 换一张
取 消