打開終端,運行cd ~/.sshgit
若是路徑下無文件,直接跳過下一步,若是有表明有ssh key,需進行第二步進行備份dom
b、備份已有的key,(若是有的話)ssh
mkdir key_backupide
mv id_rsa* key_backupfetch
c、.生成SSH key命令行
$ ssh-keygen -t rsa -C jonezhang86@gmail.com(註冊的main郵箱)blog
Generating public/private rsa key pair.ci
Enter file in which to save the key (/Users/jiangbo/.ssh/id_rsa):rem
Enter passphrase (empty for no passphrase):get
Enter same passphrase again:
Your identification has been saved in yes.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
fb:c4:b0:e0:47:fd:be:e0:fb:ea:73:ef:a8:29:d5:22 jonezhang86@gmail.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . |
| . S .. |
| . oE=o.. |
| . +o+.. |
| ..+.+.. |
| oOB=+o |
+-----------------+
4)將SSH key添加到coding上
a、打開終端,輸入open ~/.ssh,查看id_rsa.pub這個文件並打開拷貝key值
b、打開coding官網,登陸成功後,點擊帳戶-SSH公鑰,輸入a步拷貝的值,點擊提交
5)創建本地倉庫並初始化
一、命令行打開本次倉庫的文件夾目錄或者直接建立
cd !/(目錄)
二、倉庫初始化
git init
三、將項目克隆到本地倉庫
git clone URL(項目的SSH地址)
四、更新遠程更新到本地:
先打開本地倉庫的目錄,要是程序文件夾的目錄
而後輸入更新代碼命令,以下所示:
git pull
五、提交代碼
常見問題記錄FAQ
1.git pull代碼的時候報以下錯:
error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
這表示更新下來的內容和本地修改的內容有衝突,先提交你的改變或者先將本地修改暫時存儲起來
解決方法:先將本地內容存儲起來,運行命令:git stach
再git pull 便可
二、git pull的時候報以下錯:
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.
問題:打開的路徑不對
解決方法:打開本次倉庫的正確路徑,在更新代碼