初始化仓库
git init
设置user
git config --global user.name name(用户名称)
设置email
git config --global user.email email(用户邮箱)
将本地代码仓库关联到 github 上
git remote add origin https://github.com/xxxxxxxx/xxxxx.git(github仓库的地址)
如果提示fatal:remote origin already exists错误
执行git remote rm origin后再将本地代码仓库关联到 github 上
获取远程库与本地同步合并(每次提交前先拉去远程仓库的文件)
git pull --rebase origin master
添加文件到本地仓库
git add fileName(文件名称)
添加所有文件到本地仓库
git add .
提示warning: LF will be replaced by CRLF in XXXXXXXX.执行下面命令(原因是需要提交的文件是在windows下生成的,windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add . 时出现提示)
git config core.autocrlf false
本次提交的注释(提交文件之前必须执行)
git commit -m "本次提交的注释"
把本地仓库的文件推送到远程仓库
git push -u origin master
注意:
解决每次提交需要输入账号密码
git config --global credential.helper store
执行后的第一次push时需要账号密码记录到文件中后(文件地址:/c/Users/admin/.git-credentials),后面就不需要输入账号密码