Git 小记

git config --global core.quotepath false  // 解决终端中文乱码
git push --force-with-lease // 比 force 安全的强行推送

问题

fatal: pathspec '.DS_Store' did not match any files

解决办法

  1. git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch .DS_Store' --prune-empty --tag-name-filter cat -- --all
  2. git push -f origin master

参考于: https://stackoverflow.com/questions/25458306/git-rm-fatal-pathspec-did-not-match-any-files/25458504

问题:

修改已经提交过的 author 的 name 和 email

解决办法

git filter-branch --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags



git push --force --tags origin 'refs/heads/*'

参考于:https://help.github.com/en/articles/changing-author-info

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1、Git下载与安装 https://git-scm.com 选择对应macOS系统的版本进行安装; 2、Git初...
    灯花微凉阅读 2,934评论 0 5
  • 记录Git常用的一些操作 初始化仓库 git init 添加文件 git add filename 单个文件git...
    Tiny_z阅读 1,369评论 0 0
  • error:create branch Fatal: Not a gitflow-enabled repo yet...
    osbornZ阅读 2,144评论 0 0
  • 前言:最初用git时总结copy的。 clone代码: 换行符 中文乱码 常规操作: 添加到本地库 拉来其他人的更...
    清晨起床敲代码阅读 2,286评论 0 0
  • 1、安装sass01、npm install --save-dev sass-loader//sass-loade...
    丁小凯_eafe阅读 7,499评论 0 0

友情链接更多精彩内容