[英]i have two local repos, one at school one at home, and the remote repo on github, how do i get commits from one local repo to sync to the other local
[英]using git to sync two identical repos one on local and other on remote host(not github)
我在本地主机以及具有相同项目文件夹的远程主机上安装了git。
因此,本地主机上的1个仓库和远程主机上的1个仓库都包含相同的文件。 我想做的是使用localhost文件进行开发,然后将其推送到远程进行更新。
怎么做呢?
只需将远程添加到本地存储库,然后推送到远程主机即可。
git remote add origin /url/remotehost/bare_repo
git push --all
为此,您的远程主机必须有一种方法可以由本地主机通过一种受支持的协议进行访问:
您的远程主机必须具有裸仓库 ,才能推送到该仓库。
在该裸仓库上,您可以声明一个接收后钩子,该钩子将在远程主机项目文件夹中签出接收到的内容 。
OP选择了ssh( ssh://202.XXX.xx.xx:/path/to/repo.git
),但是在获取/推送时出现问题。
克隆远程仓库也无法正常工作,给我错误
Bad port '' fatal: Could not read from remote repository.
我建议指定在远程服务器上拥有该存储库的用户。
例如' git
': git@202.XXX.xx.xx
。
然后尝试使用和不使用' :
':
git@202.XXX.xx.xx:/path/to/repo.git
# or
git@202.XXX.xx.xx/path/to/repo.git
sshd必须正在运行。 该端口应为默认端口(22)。
可以在服务器端( /var/auth/log
)检查sshd日志 。
毕竟,Op报告安装程序正在运行。
post-receive
挂钩必须放在服务器上的裸仓库中,并使其可执行:
cat > /path/to/bare/repo.git/hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/path/to/live/folder GIT_DIR=/path/to/bare/repo.git git checkout -f
chmod +x /path/to/bare/repo.git/hooks/post-receive
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.