git修改user.name和user.email后找回之前的commit
2018-04-02 11:24
351 查看
当你修改你的user.email后之前提交的commit将不“属于”你,在你github主页上也没有相关的commit记录。那么如何找回这些commit呢。
原文链接:GitHubHelp
1.使用下面命令重新clone你的仓库。repo指你的仓库名
git clone --bare https://github.com/user/repo.git cd repo.git
2.使用git log查看之前commit的email
git log
3.使用第二步骤得到的email替换OLD_EMAIL,使用你目前期望使用的用户名替换CORRECT_NAME,将新的email填入CORRECT_EMAIL
#!/bin/sh 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
4.运行上述脚本
sh change.sh
5.git log查看是否已经更改成功
6.将更改后的记录提交到GitHub
git push --force --tags origin 'refs/heads/*'
7.清除当前项目
cd .. rm -rf repo.git
原文链接:GitHubHelp
相关文章推荐
- 如何修改git全局初始化的用户名和邮箱? (git修改user.name 和user.email)
- Git之user.name&user.email配置的影响及修改+备份工作成果
- git修改user.name和user.email
- git bash笔记-配置/修改git的user.name/email
- 如何修改git全局初始化的用户名和邮箱? (git修改user.name 和user.email)
- git修改user.name和user.email
- Git在提交的时候:user name and email must be set brfore commit.
- git下修改已经提交N次代码的user.name和user.email
- git修改name和email
- git修改name和email
- Git查看并修改name和email
- [Git] 修改之前某次 commit 日志和内容
- git提交错误 git config --global user.email "you@example.com" git config --global user.name "Your Name
- git 修改commit日期为之前的日期
- git配置user.name和user.email
- 【Mac使用基础】git config 全局配置,user.name和user.email 设置
- git 修改commit日期为之前的日期
- git修改已初始化配置过的user.name
- git修改上一次提交之前的提交git commit --fixup
- git commit Please tell me who you are it config --global user.email "you@example.com"