Skip to content

Instantly share code, notes, and snippets.

@defvol
Created October 9, 2015 00:11
Show Gist options
  • Select an option

  • Save defvol/2bc0c3cff0d749121453 to your computer and use it in GitHub Desktop.

Select an option

Save defvol/2bc0c3cff0d749121453 to your computer and use it in GitHub Desktop.
Git commits traveling through time
require 'git'
require 'logger'
require 'active_support/all'
g = Git.open(ENV['PWD'], :log => Logger.new(STDOUT))
g.log(100).each do |commit|
actual = commit.author.date
future = actual + 6.months
%x(git filter-branch -f --commit-filter '
if [ "$GIT_COMMIT" = "#{commit.sha}" ]
then
export GIT_AUTHOR_DATE="#{future.asctime}";
export GIT_COMMITTER_DATE="#{future.asctime}";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD)
end