Discard all commits of a specific author from a specific time

I want to return all commits by a specific author from 4 days ago. How to do it?

To get all sha1 (with a little noise), I can use this:

git log --author=Mohsen --pretty=one --since=4.days 
+6
source share
1 answer

You must specify format:%H in git log and use a loop:

 for sha in `git log --pretty=format:%H --author=Mohsen --since=4.days`; do git revert --no-edit $sha done 

This will create one latch per return. Disable the --no-edit option to interactively change the commit message each time it returns.

Or, if you want to do one big commit reverse:

 for sha in `git log --pretty=format:%H`; do sharange="$sharange $sha"; done git revert $sharange --no-commit git commit -m "reverted commits $sharange" 
+7
source

Source: https://habr.com/ru/post/950586/


All Articles