·下载安装
·对于要操作的项目,右键项目文件夹,选择“Open Git Bash here”
·如果以前没使用过Git,进行全局初始化:
# git config --global user.name "myname"
# git config --global user.email "xxx@qq.com"
·如果弹窗登录,进行登陆
·执行 “ git init ”执行成功,在选中的目录下会生成 .git 文件,是个隐藏文件
·执行 “ git add . ”,最后的 “ . ”表示将目录下所有文件添加到git仓库,可替换成单个文件名
·执行 " git commit -m "xxx" ",-m跟的是提交的说明信息
·关联远程仓库:
# git remote add origin https://github.com/test-prj/test.git
如果显示“fatal:remote origin already exisit”,说明以前关联过,想重新关联,执行:
# git remote rm origin
再重新关联:
# git remote add origin https://github.com/test-prj/test.git
·如果远程仓库为空,直接提交(“-u” 只有第一次提交需要):
# git push -u origin master
·如果远程仓库有内容,比如有个“README”文件,与本地不一致,先拉取合并:
# git pull --rebase origin master
如果出现报错:fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.
可能是之前意外中断过,需要先执行:
# git rebase --quit
再提交:
# git push -u origin master
·不报错,查看是否push成功