git 首次上传到码云

1、在码云新建项目仓库。
2、在本生成 .git文件夹

1
$ git init

3、关联远程仓库

1
$ git remote add origin [email protected]:jie163/test.git

4、将远程仓库的README文件pull下来

1
$ git pull origin master

5、将所有代码add一下(后面要加上点)

1
$ git add .

6、本次提交的注释

1
$ git commit -m "first commit"

7、将项目上传远程仓库

1
$ git push origin master

可以查看当前状态

1
$ git status

完美结束提交

常见错误

1
2
3
4
5
error: failed to push some refs to '[email protected]:jie163/test.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决办法:使用强制push的方法

1
$ git push -u origin master -f