github創建倉庫 -> 本地完成編碼 -> 上傳到githubgit
若是選擇license的話,會在當前倉庫裏有一個LICENSE文件github
mkdir helloworld cd helloworld git init
git add * git commit -m "initial version"
git remote add origin git@github.com:zhuzhzh/helloworld.git
默認的話,直接上傳會遇到"non-fast-forward"以下錯誤服務器
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:zhuzhzh/helloworld.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
緣由是本地的提交不匹配遠程版本庫最新提交,若是覆蓋的話會致使服務器端數據丟失fetch
因此須要先合併本地和遠程的代碼編碼
git fetch origin git merge origin/master
git push origin master