溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

利用git讓服務(wù)器網(wǎng)站與本地同步 ssh配置

發(fā)布時(shí)間:2020-06-19 01:31:14 來(lái)源:網(wǎng)絡(luò) 閱讀:894 作者:xmyID 欄目:開(kāi)發(fā)技術(shù)

嘛,就是將服務(wù)器上的網(wǎng)站和本地同步。
方法1
首先是上傳服務(wù)器上的網(wǎng)站到github倉(cāng)庫(kù)
git init
git add .
git commit -m ''
關(guān)聯(lián)遠(yuǎn)程倉(cāng)庫(kù),先去github上新建一個(gè),new repository
git remote add origin 你的遠(yuǎn)程庫(kù)地址
同步 合并
git pull --rebase origin master
推送
git push -u origin master
克隆
git clone git@github.com:jaxma/pig.git pig

ssh的問(wèn)題
查看有沒(méi)有id_dsa.pub

cd ~/.ssh

沒(méi)有的話

ssh-keygen -t rsa -C "your_email@youremail.com"

比如我的

git@github.com:jaxma

cat ~/.ssh/id_rsa.pub

復(fù)制公鑰

到SSH and GPG keys里添加

方法2
服務(wù)器git倉(cāng)庫(kù)
服務(wù)器倉(cāng)庫(kù)就相當(dāng)于中轉(zhuǎn)站,只要用git remote add origin命令推送過(guò)后,本地倉(cāng)庫(kù)和服務(wù)器要同步的文件夾都可以進(jìn)行push、pull操作
hook 本地push的同時(shí)讓服務(wù)器更新文件

https://blog.csdn.net/qq_34284638/article/details/70154557

方法3
用github的webhook
如果有寶塔的話用寶塔的webhook
https://www.bt.cn/bbs/thread-5348-1-1.html

更新:
克隆時(shí)端口不是22的問(wèn)題
加ssh://
例如
git clone ssh://git@ip:端口/home/git/xx.git

權(quán)限
chown -R root:root pig.git/

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI