ForeverConfused ForeverConfused - 1 year ago 86
Git Question

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

I can do "git remote add origin x@x:~/blah" and "git push" will work. But if 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?

Answer Source

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:

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".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download