[英]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.