follow - git push-u option




How can I have it to where “git push” pushes to local repositories? (2)

I can do git remote add origin [email protected]:~/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?


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.


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





git