如何将本地Git仓库推送到另一台电脑上?
我的笔记本电脑上设置了本地 Git 存储库。我想把它推到我的桌面上。
我怎样才能做到这一点?
I have a local Git repository setup on my laptop. I would like to push it to my desktop.
How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您有权访问共享目录,则可以(请参阅
git clone
< /a> 和git 远程
):这将创建一个 裸存储库,在您的本地存储库中引用为“桌面”。
由于它是裸露的,因此您可以推入它(如果需要也可以从中拉出)
作为 ProGit书中提到,git确实支持文件协议:
If you have access to a shared directory, you can (see
git clone
andgit remote
):That will create a bare repo, referenced in your local repo as "desktop".
Since it is bare, you can push to it (as well as pull from it if needed)
As the ProGit book mentions, git does support the file protocol:
这是我为完成此任务而编写的脚本。该脚本处理我对新 git 存储库的所有常规初始化
http://gist.github.com/410050
你肯定必须修改它以适应你所拥有的任何设置,特别是如果你正在处理配备 Windows 笔记本电脑/台式机。
这是完整的脚本:
Here's a script that I wrote to do just this thing. The script handles all my usual initialization of new git repos
http://gist.github.com/410050
You'll definitely have to modify it to suit whatever setup you've got, especially if you're dealing with Windows laptop/desktop.
Here is the full script:
最简单(不是最好)的方法是通过 LAN 共享存储库目录,并使用 git 的
file://
协议(请参阅man git
)。对我来说,最好的方法是使用
gitolite
(参见 gitolite 文档 了解详细说明)。The easiest (not the best) way is to share the repository directory via LAN, and use git's
file://
protocol (seeman git
).For me, the best way is to use
gitolite
(see gitolite docs for detailed instructions).