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
git - The revocation function was unable to check revocation for the certificate
git config --global http.schannelCheckRevoke false
原因:
This error is also commonly hit when you’re on a corporate network that performs MITM on all traffic, and then blocks the revocation check. While, obviously, the ideal situation is to not block the checks (or at least, to a whitelist of urls), it may be required to work around this problem.
更多推荐

所有评论(0)