git修改commiter date
GIT: change commit date to author date
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
Short Answer:
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
Explanation:
filter-branch
lets you rewrite your git history. It can apply transformations to each commit or filter out commits based on certain criteria. See git filter-branch --help
for a comprehensive description and usage instructions.
--env-filter
allows you to set the environment variables that are present during the creation of the new history. It is evaluated for each commit separately.
https://git-scm.com/docs/git-filter-branch
--env-filter <command>
This filter may be used if you only need to modify the environment in which the commit will be performed. Specifically, you might want to rewrite the author/committer name/email/time environment variables (see git-commit-tree[1] for details).
The --env-filter
option can be used to modify committer and/or author identity. For example, if you found out that your commits have the wrong identity due to a misconfigured user.email, you can make a correction, before publishing the project, like this:
git filter-branch --env-filter '
if test "$GIT_AUTHOR_EMAIL" = "root@localhost"
then
GIT_AUTHOR_EMAIL=john@example.com
fi
if test "$GIT_COMMITTER_EMAIL" = "root@localhost"
then
GIT_COMMITTER_EMAIL=john@example.com
fi
' -- --all
To restrict rewriting to only part of the history, specify a revision range in addition to the new branch name. The new branch name will point to the top-most revision that a git rev-list of this range will print.
Consider this history:
D--E--F--G--H
/ /
A--B-----C
To rewrite only commits D,E,F,G,H, but leave A, B and C alone, use:
git filter-branch ... C..H
To rewrite commits E,F,G,H, use one of these:
git filter-branch ... C..H --not D
git filter-branch ... D..H --not C
Example
git filter-branch ... origin/master..master --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
错误提示
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
错误处理
git filter-branch ... origin/master..master --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' -f
fatal: ambiguous argument 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
把-f参数放前面更好,
git filter-branch -f ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
Use this command to remove original backup:
git update-ref -d refs/original/refs/heads/master
Here is gist I used to filter-branch my git repo: https://gist.github.com/k06a/25a0214c98bc19fd6817
错误的详细信息
$ git_trace=1 gcm_trace=1 git filter-branch -f ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
23:57:28.715959 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
23:57:28.720945 git.c:676 trace: exec: git-filter-branch -f ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
23:57:28.720945 run-command.c:643 trace: run_command: git-filter-branch -f ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
23:57:29.016157 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:29.018152 git.c:419 trace: built-in: git hash-object -t tree nul
23:57:29.159774 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:29.605584 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:29.610570 git.c:676 trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
23:57:29.610570 run-command.c:643 trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
23:57:29.647472 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:29.755185 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:29.762166 git.c:676 trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
23:57:29.762166 run-command.c:643 trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
23:57:29.803057 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.180050 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.182045 git.c:419 trace: built-in: git rev-parse --git-dir
23:57:30.364558 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.366552 git.c:419 trace: built-in: git rev-parse --show-cdup
23:57:30.644809 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.646804 git.c:419 trace: built-in: git rev-parse --git-path objects
23:57:30.838293 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.840287 git.c:419 trace: built-in: git rev-parse --is-bare-repository
23:57:30.981909 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:30.984902 git.c:419 trace: built-in: git rev-parse --verify HEAD
23:57:31.134502 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:31.145474 git.c:419 trace: built-in: git update-index -q --ignore-submodules --refresh
23:57:31.294076 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:31.307041 git.c:419 trace: built-in: git diff-files --quiet --ignore-submodules
23:57:31.449662 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:31.460631 git.c:419 trace: built-in: git diff-index --cached --quiet --ignore-submodules HEAD --
23:57:32.077983 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:32.088954 git.c:419 trace: built-in: git for-each-ref
23:57:32.247530 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:32.250523 git.c:419 trace: built-in: git rev-parse --no-flags --revs-only --symbolic-full-name --default HEAD ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
23:57:32.817010 exec-cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
23:57:32.819004 git.c:419 trace: built-in: git rev-parse --no-revs ... 67d9d9..f70bf4 --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
fatal: ambiguous argument 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
发现命令参数的位置有问题,做出如下调整(commits的范围要放在最后面)
https://stackoverflow.com/questions/15250070/running-filter-branch-over-a-range-of-commits
git_trace=1 gcm_trace=1 git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' ... 67d9d9..f70bf4
https://github.com/git-for-windows/git/issues/2206
git_trace=1 gcm_trace=1 git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' origin/master..master
git filter-branch -f --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' origin/master..master
git修改commiter date的更多相关文章
- git: 修改commiter 信息
Committer: root root@localhost.localdomain 您的姓名和邮件地址基于登录名和主机名进行了自动设置.请检查它们正确 与否.您可以通过下面的命令对其进行明确地设置以 ...
- git修改文件名大小写的方法。
首先,在git命令行里面运行: git config core.ignorecase false 此命令是全局设置,以后在此机子上clone出来的git仓库工程都沿用此设置.当然,以前就已经clone ...
- git 修改历史提交信息
当你不小心,写错了提交的注视/信息,该如何处理呢.理论上,SCM是不应该修改历史的信息的,提交的注释也是. 不过在git中,其commit提供了一个--amend参数,可以修改最后一次提交的信息. ...
- Git 修改用户名以及提交邮箱
问题背景: 在已毕业师兄的电脑上提交自己的 Github 代码,(尽管有重新设置了 自己的SSH),但是 Github网站提交结果却显示师兄提交的: 验证当前本地属性: 怎么知道本地有设置?git c ...
- git修改用户名以及邮箱
git 修改当前的project的用户名的命令为:git config user.name 你的目标用户名; git 修改当前的project提交邮箱的命令为:git config user.emai ...
- [转]git修改远程仓库地址
原文链接:http://www.cnblogs.com/lazb/articles/5597878.html 问:Coding远程仓库地址变了,本地git仓库地址如何更新为最新地址 git修改远程仓库 ...
- git 修改commit 的注释
git 修改commit 的注释 一:最新的一次提交 当你不小心,写错了提交的注视/信息,该如何处理呢.理论上,SCM是不应该修改历史的信息的,提交的注释也是. 不过在git中,其commit提 ...
- git 修改已提交了的备注信息的方法
git 修改已提交了的备注信息的方法: 1.当我们已通过 git commit -m '已提交的最新的备注' 命令将代码提交到了缓存区,或者进一步执行了 git push origin master ...
- git 修改最后一次提交
git 修改最后一次提交 有时候我们提交完了才发现漏掉了几个文件没有添加,或者提交信息写错了. 此时,可以运行带有 --amend 选项的提交命令来重新提交:git commit --amend -m ...
随机推荐
- Spring MVC浅析
讲到MVC,想必大家都很熟悉,就是将数据模型.视图.控制器进行分离,做到分工明确,在Spring的帮助下,Spring MVC 更是做到了充分的解耦,因为大部分的资源都由Spring进行管理,为Spr ...
- 个人珍藏的PC和安卓应用列表
个人珍藏的PC和安卓应用列表 PC应用名称 功能描述 注意事项 存储位置 维棠FLV视频下载软件 可用来下载腾讯视频的视频 将视频列表的网址粘贴到维棠软件左侧"下载"的地址中即可批 ...
- EasyUI的datagrid列属性添加超链接
$("#dg").datagrid({ url: "../Ajax/PurchaseAjax.ashx", queryParams: ...
- mybatis入门总结一
1.parameterType 表示输入参数的类型 2.resultType 表示输出结果的类型 不管输出的是一条还是多条,都只代表单条记录所映射的java对象类 3.#{} 表示sql语句中的占位 ...
- Nacos-作为Sring cloud 注册发现
Nacos:一个更易于构建云原生应用的动态服务发现.配置管理和服务管理平台. https://nacos.io/zh-cn/index.html 功能: 动态服务配置 服务发现和管理 动态DNS服务 ...
- hdu5858 Hard problem(求两圆相交面积)
题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- .net 异步
原文:https://www.cnblogs.com/wisdomqq/archive/2012/03/26/2412349.html 在说到异步前,先来理一下几个容易混淆的概念,并行.多线程.异步. ...
- vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin
场景: . webpack2.4.*集成vue-loader@15.7.2报错 原因: 参考官方文档 https://vue-loader.vuejs.org/migrating.html#a-plu ...
- js利用递归与promise 按顺序请求数据
问题:项目中有一个需求,一个tabBar下面如果没有内容就不让该tabBar显示,当然至于有没有内容,需要我们通过请求的来判断,但是由于请求是异步的,如何让请求按照tabBar的顺序进行? 方案:我们 ...
- C Primer Plus 学习 第三章
这里只记录我自己以前不懂得地方,明白的地方就略过了 位 字节 字 位 0,1 字节 8位 也就有8位0,1的组合 2的8次方的组合 字 设计计算机时给定的自然存储单元.8位 ...