Reverting Modified Source Control Files—Git

If you have modified files from source control but do not want to keep your modifications, you can use the "Revert" option instead of committing the files. While committing the file would save your changes to source control, reverting a file returns it to its previously committed state and does not commit any of your new changes to source control. When reverting changes made in Git, you only revert changes to the file on the branch you are currently editing. If you have a file that resides on multiple branches, copies of the file on other branches are preserved.

How to Revert a Source Control File

  1. In the Source Control Explorer or File List, select the relevant file(s).

  2. Do one of the following, depending on the part of the user interface you are using:
    • Ribbon Select Source Control > Revert (for selected files) or Source Control > Revert All (for all files in the project).

    • Right-Click In the File List, right-click the files you want to revert and select Source Control > Revert (for selected files) or Source Control > Project > Revert All (for all files).

    • Local Toolbar In the File List, select the file(s) you want to revert. In the local toolbar of the File List, click , then select Revert (for selected files) or Project > Revert All (for all files in the project).

    A dialog opens. The selected files are listed with check boxes next to them.

  3. (Optional) If you want to see all files with pending changes (rather than only those you selected), click .

  4. Make sure to click the check box next to each appropriate file so that it contains a check mark.

  5. Click Revert.