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