1. 程式人生 > >「git」mac下git提交github程式碼

「git」mac下git提交github程式碼

1.開啟終端,輸入

cd ~/.ssh

這個是檢查你的ssh的是否存在的,如果存在,先將已有的ssh備份,或者將新建的ssh生成到另外的目錄下(如果第一次配置一般都是不存在的),不存在,你將會看到如下:

 

接下來你就需要用預設的引數生成ssh,終端輸入

ssh-keygen -t rsa -C [email protected]

這裡的[email protected] 就是你註冊github時的郵箱地址,比如我的是[email protected],那麼我的終端就應該輸入

ssh-keygen -t rsa -C 

[email protected]

然後一直回車,直到這樣

 

如果要修改ssh生成目錄,在粗體位置處輸入要生成的路徑,選擇預設的話,會生成在 ~/.ssh

2.開啟你的github,按著下面的步驟

 

點選左側的New SSH key 然後新增

這裡寫圖片描述

上面的 
Title:填寫你註冊的郵箱號,這裡就是[email protected] 
key :填寫你的生成的id_rsa.pub 檔案將裡面的內容copy到此

/Users/fengnovo/.ssh/id_rsa.pub   複製到前往即可

這裡寫圖片描述

 

選擇文字編輯開啟即可。

3.測試一下你的賬號跟github連上了沒有,開啟終端,輸入

ssh -T [email protected]

如果出現

Hi Loveway! You've successfully authenticated, but GitHub does not provide shell access.

就表示你已經連上了,如圖

4.

 在github新建git

複製程式碼
touch README.md //新建一個記錄提交操作的文件
git init //初始化本地倉庫
git add README.md //新增
git add *  //加入所有專案
git status //檢查狀態 如果都是綠的 證明成功
git commit -m "first commit"//提交到要地倉庫,並寫一些註釋
git remote add origin 
[email protected]
:youname/Test.git //連線遠端倉庫並建了一個名叫:origin的別名 git push -u origin master //將本地倉庫的東西提交到地址是origin的地址,master分支下
複製程式碼

出錯:
1.git commit -m 'test'   出現下面錯誤

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "lint" npm ERR! node v7.2.1 npm ERR! npm v3.10.10 npm ERR! missing script: lint npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <https://github.com/npm/npm/issues>

.git/hooks目錄下的所有檔案都刪掉。參考https://github.com/ruanyf/jstraining/issues/24


參考連結
http://www.jianshu.com/p/3cc188964dbf

https://apple.stackexchange.com/questions/93002/how-to-properly-update-git-on-mac
http://www.jianshu.com/p/e7501b968256
http://www.07net01.com/2015/08/895617.html
https://github.com/ruanyf/jstraining/issues/24