1、在本地文件目录下,选中要提交的文件,右键点击Git Bash Here进入文件目录
2、链接远程仓库:git remote add origin git@github.com:134251796/lxy.git(远程仓库地址)
3、添加当前目录的所有文件到暂存区:git add .(点的意思是所有文件)
4、提交文件:git commit -m “描述信息”
5、上传本地分支到远程仓库:git push -u origin master
【注】如果git push报错 error:failed to push some refs to 'git@github.com:134251796/lxy.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 pull --rebase origin master
$ git push -u origin master