[英]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. 我可以做git remote add origin x@x:~/blah
和git push
会起作用。 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. 但是如果我在/ var中创建一个本地拷贝git clone ~/blah
,那么git remote add local /var/blah
里面~/blah
,当我尝试git push
它不会推送更新。
How can I make git push updates to local copies? 如何对本地副本进行git推送更新?
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. 我在其他文件夹中使用git clone
来获取库的本地副本。 When I update the main library I have to go to each local copy and type git pull
to get the updates? 当我更新主库时,我必须转到每个本地副本并输入git pull
来获取更新? How can I say git push
to push code to all libraries? 我怎么能说git push
将代码推送到所有库?
By default, git push
pushes to origin. 默认情况下, git push
推送到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>
. 如果要推送到不同的远程存储库(在同一台机器上或其他机器上),则需要执行git push <remote-name>
。 Also keep in mind what mipadi says about non-bare repositories. 还要记住mipadi关于非裸存储库的说法。
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. 所以在你的情况下,在git remote add local /var/blah
,你会执行git push local
来将更改推送到/ var / blah中的repo。
A little google-fu came up with this post for pushing to multiple remote repositories at once: 有点google-fu想出了这篇文章,立即推送到多个远程存储库:
http://web.archive.org/web/20110828185858/http://jeetworks.com/node/22 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: 要做到这一点,编辑你的.git / config并输入如下内容:
[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 push all
来推送远程“all”指向的两个远程URL。
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. 如果是,则将更新repo本身,但不会更新签出(磁盘上)文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.