简体   繁体   English

我如何才能将“git push”推送到本地存储库?

[英]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:~/blahgit 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.

相关问题 我怎样才能让多个项目在一个 GitHub 存储库中拥有自己的本地 git 存储库? - How can I have multiple projects with their own local git repositories in one GitHub repository? 如果没有通过单元测试,如何拒绝来自本地仓库的原始仓库的git推送? - How can I reject git pushes on an origin repo from a local repo if it does not pass unit tests? 设置本地git分支在哪里推送和推送 - Setting where a local git branch pulls AND pushes 我应该如何设置我的Git存储库以能够在两个地方同时推送并仍具有工作目录? - How should I setup my Git repositories to be able to push and still have a working directory at both places? 当两者都在防火墙/ NATs / ...后面时,如何在git存储库之间推/拉? - How can I push/pull between git repositories when both are behind firewalls/NATs/…? 如何设置我的.git / config以便能够从多个远程存储库推送/拉出? - How can I setup my .git/config to be able to push to / pull from multiple remote repositories? 如何使用 git 从我的 PC 推送到多个 GitHub 帐户? (不同的存储库) - How can I push to multiple GitHub accounts from my PC using git? (different repositories) Git:创建了本地和远程存储库,如何使用推送到远程存储库的文件? - Git: Created a local and remote repositories, how can I use the files I pushed to the remote repository? Git推什么也没推 - Git push pushes nothing 如何记录我本地的 git 推送历史? - How can I record my local git push history?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM