Revert all commits by a specific author since specific time

假装没事ソ 提交于 2019-12-21 04:23:22

问题


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

To get all sha1s (with a bit of noise) I can use this:

git log --author=Mohsen --pretty=one --since=4.days

回答1:


You have to give format:%H to 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 commit per revert. Suppress the --no-edit option to modify interactively the commit message on each revert.

Or, if you want to make one big revert commit:

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


来源:https://stackoverflow.com/questions/17935750/revert-all-commits-by-a-specific-author-since-specific-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!