我想回退某个作者在4天前以来的所有提交。我该怎么做?
为了获取所有sha1(带有一些噪音),我可以使用以下命令:
git log --author=Mohsen --pretty=one --since=4.days
我想回退某个作者在4天前以来的所有提交。我该怎么做?
为了获取所有sha1(带有一些噪音),我可以使用以下命令:
git log --author=Mohsen --pretty=one --since=4.days
您需要给git log
命令加上format:%H
选项,并使用循环:
您必须向git log
提供format:%H
,并使用循环:
for sha in `git log --pretty=format:%H --author=Mohsen --since=4.days`; do
git revert --no-edit $sha
done
这将创建每个还原操作一个提交。删除--no-edit
选项,以便在每个还原操作上交互式修改提交消息。
或者,如果你想要创建一个大还原操作提交:
for sha in `git log --pretty=format:%H`; do sharange="$sharange $sha"; done
git revert $sharange --no-commit
git commit -m "reverted commits $sharange"
git revert --continue
继续进行撤销操作。 - CharlesB
git reset
的位置。另外,您想要执行“还原”(revert)还是“重置”(reset)?它们有一点不同。 - BlackVegetable