在window下安裝github客戶端上傳代碼linux
第一步:建立Github新帳戶git
第二步:新建倉庫github
第三步:安裝Github shell程序,地址:http://windows.github.com/shell
第四步:打開Git Shell,輸入如下命令生成密鑰來驗證身份windows
$ ssh-keygen -C 'your@email.address' -t rsa服務器
連續三個回車以後會在windows當前用戶目錄下生成.ssh文件夾,和linux同樣。ssh
第五步:在Git Shell下輸入命令測試剛纔的公鑰是否定證正確。測試
$ ssh -T git@github.comfetch
第六步:clone剛纔新建的repository 到本地,輸入命令:命令行
git clone https://github.com/XXXXX/XXXXXX.git
第七步:將想上傳的代碼目錄拷貝到此文件夾下:
第八步:切換到Git shell 命令行下,輸入命令:
git init
git add .
git commit -m 'xxxxxx'
git remote add origin https://github.com/xxxxx/xxxxx.git
git push origin master
(1)若是執行git remote add origin https://github.com/xxxxx/xxxxx.git,出現錯誤:
fatal:remote origin already exists
則執行如下語句:
git remote rm origin
再日後執行git remote add origin https://github.com/xxxxx/xxxxx.git便可。
(2)在執行git push origin master時,報錯:
$ git push origin master
To https://github.com/qq20707/DesignPatterns.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/qq20707/DesignPatterns.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.
error:failed to push som refs to .....
則執行如下語句:git pull --rebase origin master
(3)若是出現錯誤 「refusing to merge unrelated histories」
git pull origin master --allow-unrelated-histories
先把遠程服務器github上面的文件拉先來,再push 上去。