1.git永久保存账户名和密码
1.1 git config --global credential.helper store
1.2 git pull
1.3 输入账号密码(只要使用一次账号密码就行,不用管‘git pull’是否成功)
done
2.git pull时报错’Please commit your changes or stash them before you merge‘
2.1 直接覆盖本地的代码
git reset --hard
git pull
2.2 需要保存本地的代码
git stash (先把本地的代码保存)
git pull (拉取仓库代码)
git stash pop (拉取本地代码)
解决冲突
3.解决冲突
git pull (+主分支)
解决冲突
git add .
git commit -m “update”
git push
提MR
4.git clone的各种情况
4.1 clone指定分支
git clone -b XX http://10.1.1.11/service/tmall-service.git
4.2源码中有子模块链接
git clone --recurse-submodules https://github.com/chaconinc/MainProject.git
如果给 git clone
命令传递 --recurse-submodules
选项,它就会自动初始化并更新仓库中的每一个子模块, 包括可能存在的嵌套子模块
如果你已经克隆了项目但忘记了 --recurse-submodules
,那么可以运行:
git submodule update --init --recursive
这个命令的作用:初始化、抓取并检出任何嵌套的子模块
5.更新代码
5.1 git pull指定分支
git pull http://192.168.2.203/compiler/ai_compiler.git XX
5.2 更新子模块链接
git submodule update --remote --init --recursive
为安全起见,如果 MainProject 提交了你刚拉取的新子模块,那么应该在 git submodule update
后面添加 --init
选项,如果子模块有嵌套的子模块,则应使用 --recursive
选项
5.2 使git pull时,自动拉取更新子模块,可以这样设置:
git config --global submodule.recurse true
设置之后,所有支持 --recurse-submodules
的git命令都会使用该选项(除 clone
以外)