github - git: how to remove all commits with a pattern? -


we use git source control. each time there commit developers, script modify build file , checks in file. script commits build file message follows pattern. commit history following:

  • script checkin build file 003
  • fix bug
  • script checkin build file 002
  • resolve story

what want remove commits script. now, obviously, different removing particular commit.

i have freedom start brand new repository copying existing repository, still want preserve "developer's commit history" as possible, while getting rid of "script's commit history".

is possible?

note - "script's commits" changed single file (that is, build file), , did not change other file. and, no "developer's commit" ever changed particular file.

so far have been doing run "bfg tool" delete particular build file git repo. commits script ever changed build file, hoping removing build file, associated commits squashed away git.

but, found is: build file gone, yet commits preserved, , commits, curiously, having "0 changes".

so next question is: possible ask git remove commits "0 changes"?

you can use git filter-branch. easy way if script has unique author name. can like:

git filter-branch --commit-filter '     if [ "$git_author_name" = "script person" ];             skip_commit "$@";     else         git commit-tree "$@";     fi' head 

this pretty right out of man page. there few different variables can check against if there's else uniquely identifies script committer.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -