记录经常使用的git命令

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 以外)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值