git常用命令

git revert多个提交

假如git commit 链是

A -> B -> C -> D
如果想把B,C,D都给revert,除了一个一个revert之外,还可以使用range revert
git revert B^..D
这样就把B,C,D都给revert了,变成:
A-> B ->C -> D -> D’-> C’ -> B’
用法就是:
git revert OLDER_COMMIT^..NEWER_COMMIT
如果我们想把这三个revert不自动生成三个新的commit,而是用一个commit完成,可以这样:

git revert -n OLDER_COMMIT^..NEWER_COMMIT
git commit -m "revert OLDER_COMMIT to NEWER_COMMIT"

git pull报错(unable to update local ref)

解决办法:

git gc --prune=now
git remote prune origin

参考: https://stackoverflow.com/questions/10068640/git-error-on-git-pull-unable-to-update-local-ref

git submodule删除子模块

git rm -r the_submodule
rm -rf .git/modules/the_submodule

参考: https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule

git 脚本没有执行权限 Permission denied for build.sh file

git update-index --add --chmod=+x build.sh
git commit -m 'Make build.sh executable'
git push

参考: https://stackoverflow.com/questions/42154912/permission-denied-for-build-sh-file

git push error: dst refspec refs/heads/main matches more than one

# 查找master相关tag
git tag |findstr master
refs/heads/master

# 删除本地tag
git tag -d refs/heads/master

# 推送
git push origin :refs/tags/refs/heads/master

参考:
https://stackoverflow.com/questions/70584317/git-push-error-dst-refspec-refs-heads-main-matches-more-than-one
https://blog.csdn.net/qq_39779233/article/details/108037090

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值