1. 程式人生 > >window端GitHub託管程式碼

window端GitHub託管程式碼

一些前期配置見部落格 點選開啟連結 1、下載GitHub的bash和Windows desk版本,在使用者目錄下生成自己的公鑰.pub cd ~ ssh-keygen -t rsa  一直enter 2、把使用者公鑰貼上GitHub網站的ssh key那,下次免密上傳 https://www.zhihu.com/question/21402411 3 第一次進入時:echo "# f2fsCode" >> README.md git init git add README.md
git commit -m "first commit" git remote add origin [email protected]:xixiss/f2fsCode.git git push -u origin master
以後每次提交: git add 檔名 git commit -m "修改描述" git push 4、git的客戶端和網頁端都能檢視最近的更改。客戶端還能回滾
使用遇到的問題 $ git push
To github.com:xixiss/f2fsCode.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '
[email protected]
:xixiss/f2fsCode.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
這是因為local版本和遠端版本不一致造成的(不一致的原因是再客戶端和bash兩個地方同時更改,造成了版本不一致),需要同過git pull 操作,拉取遠端程式碼,使得版本同步,才能繼續push

所以在協同操作時,每次操作要確保自己寫的local版本與remote版本一致:寫之前先pull一次!!!! 這樣,每次編輯之前,都是最新版本,協同操作也變成了版本的迭代,就像一個人在一直提交一樣(一個人不用pull的原因是,每次他寫好的程式碼,push上去之後,沒有別人去改,於是本地和遠端程式碼一直一致,因此不用pull)