1.修改author和committer

git filter-branch --commit-filter '
export GIT_AUTHOR_EMAIL=me@example.com;
export GIT_AUTHOR_NAME=me;
export GIT_COMMITTER_EMAIL=me@example.com;
export GIT_COMMITTER_NAME=me;
git commit-tree "$@"
'

2.删除误提交的文件

a.用git filter-branch对所有分支上的commit执行命令操作,忽略对该文件的追踪,
将其从git仓库中移除,并重写每一条记录

//从指定的commit中删除误操作文件的记录
git filter-branch --tree-filter 'git rm -f --ignore-unmatch {{文件名}}' [commit1..commit2] //从当前分支的前30次提交开始遍历,删除误操作文件的引用
git filter-branch --tree-filter 'git rm -f {{文件名}}' HEAD~..HEAD

b.强制推送到远端

git push origin master --force

出处:https://walterlv.oschina.io/git/2017/09/19/delete-file-using-filter-branch.html
出处:http://www.jianshu.com/p/099e644b60fb

git filter-branch应用的更多相关文章

  1. Git Your branch is ahead of 'origin/master' by X commits解决方法

    (1)方法1:git fetch origin (2)方法2(代码还需要):git push origin (3)方法3 (代码不需要):git reset --hard origin/$branch ...

  2. git: Your branch and 'origin/master' have diverged

    git: Your branch and 'origin/master' have diverged - how to throw away local commits? - Stack Overfl ...

  3. Git master branch has no upstream branch的解决

    Git master branch has no upstream branch的解决 在push代码时,出现“git master branch has no upstream branch”问题的 ...

  4. git branch & git remote branch

    git branch & git remote branch $ git branch -h usage: git branch [<options>] [-r | -a] [-- ...

  5. [Practical Git] Filter commit history with git log arguments

    In the last lesson, we learned how to format the git log output; in this lesson we will learn how to ...

  6. git branch(git 的branch 使用方法)

    查看分支:         $ git branch    该命令会类出当先项目中的所有分支信息,其中以*开头的表示当前所在的分支.参数-r列出远程仓库中的分支,而-a则远程与本地仓库的全部分支. 创 ...

  7. git 创建branch分支

    开发者user1 负责用getopt 进行命令解析的功能,因为这个功能用到getopt 函数,于是将这个分支命名为user1/getopt.(1)确保是在开发者user1的工作区中cd /home/j ...

  8. git 创建branch分支【转】

    转自:http://www.cnblogs.com/jackluo/p/3499731.html 开发者user1 负责用getopt 进行命令解析的功能,因为这个功能用到getopt 函数,于是将这 ...

  9. Git CMD - branch: List, create, or delete branches

    命令格式 git branch [--color[=<when>] | --no-color] [-r | -a] [--list] [-v [--abbrev=<length> ...

  10. [git] git 分支( branch ) 的基本使用

    分支( branches ) 是指在开发主线中分离出来,做进一步开发而不影响到原来主线. Git 存储的不是一系列的更改集( changeset ),而是一系列快照.当你执行一次 commit 时, ...

随机推荐

  1. JS let和const关键字

    ES2015 引入了两个重要的 JavaScript 新关键词:let 和 const. Let关键字 1.用于作用域:块作用域,循环作用域,函数作用域,全局作用域, 在 ES2015 之前,Java ...

  2. 在Drupal7中创建web接口

    Services 模块允许您从一个主要模块后端配置和管理区域启用您 Drupal 站点上自定义构建的内容服务器和服务.该模块中包含的服务允许您调用内容,从 Drupal 的默认和分配的 File.Co ...

  3. hello spring boot neo4j

    新建springboot 项目: https://www.cnblogs.com/lcplcpjava/p/7406253.html bug fixs: 1. Maven Configuration ...

  4. 四、Linux 忘记密码解决方法

    Linux 忘记密码解决方法 很多朋友经常会忘记Linux系统的root密码,linux系统忘记root密码的情况该怎么办呢?重新安装系统吗?当然不用!进入单用户模式更改一下root密码即可. 步骤如 ...

  5. Python_三级目录

    程序要求: 1. 使用字典存储 1. 可以一层一层的进入到所有层2. 可以在每层返回上一层3. 可以在任意层退出 三级目录写了两个版本,第一个版本是刚看完字典写出来的,代码很多冗余,很多重复. men ...

  6. 引用 Reference

    在Java中,判断一个对象是否 "存活" ,都和引用有关,当一个对象没有任何的引用指向它,我们可以认为这个对象可以被GC了. 引用如何定义?Object obj = new Obj ...

  7. 关于json数据中的多反斜杆转译--StringEscapeUtils.unescapeJava(踩过的坑)

    一.需求 现有一个字符串str String str = "{\\\"name\\\":\\\"spy\\\",\\\"id\\\\&quo ...

  8. 权限组件(15):rbac的使用文档和在业务中的应用

    这里用主机管理系统当做示例. 一.将rbac组件拷贝到项目中. 注意: rbac自己的静态文件.layout.html(被继承的模板).bootstrap.fontsize.公共的css.jquery ...

  9. oracle for update和for update nowait 的区别

    原文地址:http://www.cnblogs.com/quanweiru/archive/2012/11/09/2762223.html 1.for update 和 for update nowa ...

  10. adb offline解决办法

    假如你连接手机之后,adb devices找不到设备,或者找到了设备,但是device ID后总是offline的状态,那估计就是驱动有问题. 强烈建议1.安装豌豆荚,它可以自己主动修复手机驱动,一般 ...