Git 完整命令手册地址:http://git-scm.com/docs
PDF 版命令手册:github-git-cheat-sheet.pdf
1、gitee填写相关信息创建仓库后
2、在本地项目文件夹右击鼠标点击Git Bash Here
3、输入git init,这个目录变成git可以管理的仓库,会出现一个.git文件夹,如果没出现的话需要选择“显示隐藏文件”
4、绑定本地仓库与远程仓库:git remote add origin [远程仓库的具体地址]
例如:git remote add origin https://gitee.com/m666/gmds---data.git
5、添加文件到暂存区:git add .(注意后面的点表示目录下的所有文件,点前面还有一个空格不要漏掉了)
6、将暂存区的文件提交至仓库中:git commit -m '本次的提交信息'
7、远程库与本地同步合并, git pull origin master
如果这时候弹出框提示 Git for windows:Username for ‘https://gitee.com/‘:
登录即可
版本控制Git:Username for ‘https://gitee.com‘:
注意,此处可能会报错:fatal: refusing to merge unrelated histories
问题产生原因:本地库和远程库没有相关性, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并。
解决方法:操作命令后面加 --allow-unrelated-histories变为:git pull origin master --allow-unrelated-histories
8、将本地的分支版本上传到远程并合并:git push -u origin master