因爲網站的代碼都是在本地寫的而寫完之後要放到雲服務器上去,這個就比較麻煩了。網上有人說可以自己搭一個fpt來傳文件,但是這個也不是一個很大的項目,於是就想通過git和github來實現一個簡單的傳輸,也方便管理。具體步驟如下:
- 安裝Git,使用命令
sudo apt-get install git
- 生成ssh key,使用命令 “ssh-keygen -t rsa -C “[email protected]””,your_email是你的email .公匙一般默認在用戶的/home/.ssh/id_rsa.pub文件裏面。我的比較奇怪是在/root/.ssh/rsa.pub裏所以需要root權限。
- 進入到github,進入Account Settings,左邊選擇SSH Keys,Add SSH Key,title隨便填,粘貼key。
- 測試ssh key是否成功,使用命令“ssh -T [email protected]”,如果出現You’ve successfully authenticated, but GitHub does not provide shell access 。這就表示已成功連上github。
配置Git的配置文件,username和email
git config --global user.name "your name" //配置用戶名 git config --global user.email "your email" //配置email
這樣git的配置和github的鏈接就配好了,使用git clone
命令就可以克隆自己的項目了。感覺這樣子做還是很方便,也很快捷。其他的有關git和github的操作可以去看廖雪峯的博客,百度一下就有了。