---
title: "change the author of a commit in git?"
author: "夜鸣猪"
date: "2013-03-19T20:34:05Z"
tags: ["Git"]
categories: ["编程语言"]
slug: "change-the-author-of-a-commit-in-git"
draft: false
lastmod: "2013-04-16T20:53:11Z"
id: 1832106
url: "https://hlee.iteye.com/blog/1832106"
---

删除项目里的大文件 \[code="java"] git filter-branch --index-filter \\ 'find -name ''\*.mp3'' -or -name ''\*.ogg'' | xargs -d''\\n'' rm -f' #Suppose you want to remove a file (containing confidential information or copyright violation) from all commits: git filter-branch --tree-filter 'rm filename' HEAD \[/code] \[code="java"] git filter-branch --commit-filter ' if \[ "$GIT\_COMMITTER\_NAME" = "" ]; then GIT\_COMMITTER\_NAME=""; GIT\_AUTHOR\_NAME=""; GIT\_COMMITTER\_EMAIL=""; GIT\_AUTHOR\_EMAIL=""; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD \[/code] \[code="java"] export GIT\_AUTHOR\_DATE="Fri Jan 2 21:38:53 2009 -0800" export GIT\_COMMITTER\_DATE="Sat May 19 01:01:01 2007 -0700" \[/code] \[code="java"] git filter-branch -f --env-filter "GIT\_AUTHOR\_NAME='Newname'; GIT\_AUTHOR\_EMAIL='newemail'; GIT\_COMMITTER\_NAME='Newname'; GIT\_COMMITTER\_EMAIL='newemail';" HEAD git filter-branch -f --env-filter " GIT\_AUTHOR\_NAME='Newname' GIT\_AUTHOR\_EMAIL='newemail' GIT\_COMMITTER\_NAME='Newname' GIT\_COMMITTER\_EMAIL='newemail' " HEAD \[/code]