Frage

I have one GIT repository in which a number of users (Say A, B, .....X) committed the file. I want to delete or revert all the files which are committed by the User 'X'.

Is it possible or do I have to do that manually?

War es hilfreich?

Lösung

Try this:

git log --author=X --format="%H" | xargs git revert

The first part of the pipeline produces all SHA1s of commits where the username matches the regular expression (!) X; the second part calls a git revert on those commits. If one of the commits fails to revert cleanly, though, you might want to just walk through the output of

git log --author=X --oneline

and revert by hand.

Andere Tipps

I believe, you can use git revert for this. See the git manual section on this for more information.

The gist is that you can say:

git revert Where is the id of the commit you'd like to undo, and it will try to undo it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top