若最后一步出错,
ralap@Ubuntu:~/data/coder/webtest$ git push -u origin master Username for 'https://git.coding.net': sql031625 Password for 'https://sql031625@git.coding.net': To https://git.coding.net/sql031625/webtest.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://git.coding.net/sql031625/webtest.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.
原因分析:在github上重新创建仓库,建立README.md,导致该文件不在本地代码中,执行以下命令,将git 仓库中的文件与本地合并,然后再上传即可
git pull --rebase origin master git push -u oringin master
原文:http://blog.51cto.com/songqinglong/2109126