一直用git托管自己的代码,但是经常忘了命令,今天正好写下
1 建立仓库
2 克隆仓库 git clone 仓库的ssh
3 cd 仓库名
本地会多一个和仓库名一样的文件夹,文件夹下有一个.git文件
4 ls
列出该文件夹下的所有文件,把要推送的文件放在该文件夹下
5 git add 文件名
6 git commit -m "文件说明"
文件说明很重要,时间久了之后有时候查找代码不容易,或者是多次更新的代码,
7 git push -u origin master
按照上面的步骤就可以把代码推送上去啦!
注意:本地第一次推送是git remote add origin ,但是现在会提示错误,提示已经存在 .

8 出现问题:

原因:GitHub远程仓库中的README.md文件不在本地仓库中。
9 解决问题:
$ git pull --rebase origin master
$ git push -u origin master

网友评论