使用Git将本地项目上传到Git版本库
1.打开运行输入cmd打开控制台应用,进入项目文件夹,通过命令git init 把这个目录变成git可以管理的仓库(如果.git文件已存在,先删除.git文件)
git init
2.把文件添加到版本库中,使用命令 git add . 添加到暂存区里。
(注:不要忘记add后面的小数点,“.” 意为文件夹中所有文件)
git add .
3.使用命令 git commit 告诉Git,把文件提交到仓库,引号内为提交说明
(注: 如果报 Error :pathspec ‘commit’’ did not match any file(s) known to git 建议使用使用双引号试一下)
git commit 'first commit'
git commit "first commit"
4.关联到远程版本库
git remote add origin http://github.com/code.git(远程库地址)
5.获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)
git pull --rebase origin master
6、把本地库的内容推送到远程,使用 git push命令,实际上是把当前分支master推送到远程
git push -u origin master