git - 如何将本地 Git 存储库推送到另一台计算机?

标签 git git-push

我的笔记本电脑上有一个本地 Git 存储库设置。我想将它推送到我的桌面。

我该怎么做?

最佳答案

如果您有权访问共享目录,您可以(参见 git clonegit remote):

git clone --bare /path/to/your/laptop/repo /shared/path/to/desktop/repo.git
git remote add desktop  /shared/path/to/desktop/repo.git

这将创建一个 bare repo ,在您的本地存储库中引用为“桌面”。
因为它是裸露的,所以你可以推它(如果需要的话也可以 pull 它)

git push desktop

作为ProGit book mentions , git 确实支持文件协议(protocol):

The most basic is the Local protocol, in which the remote repository is in another directory on disk.
This is often used if everyone on your team has access to a shared filesystem such as an NFS mount, or in the less likely case that everyone logs in to the same computer.

关于git - 如何将本地 Git 存储库推送到另一台计算机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2888029/

相关文章:

git - git pull 会更新所有跟踪的分支吗?

git - merge 两个 Git 仓库并保留历史记录

Django React 项目结构

git - 如何设置 git 以便通过 gchat 获取消息或将某人推送到服务器?

git - RPC失败; HTTP 400 curl 22 请求的 URL 返回错误 : 400 Bad Request

git 远程存储库包含未 merge 到本地分支的提交

ruby-on-rails - Heroku:如何在 "git pull"之后到 'git push -f'

git - 防止在 Git 中推送本地更改

git - 致命的 : unable to create 'refs/heads/master.lock' : File exists fatal: - Getting this error while pushing the commits

git-commit - 为什么在不推送 git 的情况下提交?