Skip to content
Home » Revert Files to a Specific Previous Version in Git

Revert Files to a Specific Previous Version in Git

git revert multiple files

Have you ever committed files in Git, pushed them to a remote server, and later needed to revert some of them to a specific previous version or commit ID? If yes, then you’re in the right place. This guide will show you how to easily revert files to a specific previous version in Git without creating separate commits for each file.

Step-by-Step Guide to Revert Files in Git

To revert specific files to a previous version, you need the filenames and the commit ID of the version you want to revert to.

Follow these steps.

  1. Identify the Commit ID: Use the git log command to find the commit ID of the desired previous version.
  2. Revert the Files: Use the following command to revert the specified files to the identified commit ID:
git checkout <commit-id> -- <filename-1> <filename-2> ... <filename-n>

In above command:

  • <commit-id>: The commit ID to which you want to revert the files.
  • <filename-1>, <filename-2>, etc.: The names of the files you want to revert.

Now, your files are reverted to their previous states and ready to be committed.

Commit Changes Without Creating a New Commit ID

To update the latest commit with these changes without creating a new commit ID, use the following command:

git commit --amend --no-edit

In above command:

  • --amend: This option allows you to edit the latest commit and include the new changes.
  • --no-edit: This option keeps the commit message unchanged, simply adding the new file changes to the latest commit.

By following these steps, you can efficiently revert files to a previous version and update your latest commit without cluttering your commit history with new commit IDs.


Reverting files to a specific previous version in Git is straightforward and can be done without creating new commit IDs. This method helps maintain a clean commit history while ensuring your files are reverted as needed.


I hope you like this article and helps you to solve your problems.

Visit Techtalkbook to find more related topics.

Leave a Reply

Your email address will not be published. Required fields are marked *