Reverting Modified Source Control Files—Git

If you have modified files from source control but do not want to keep your modifications, use the "Revert" option instead of committing the files. While committing the file would save 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 one of the window panes (e.g., Content Explorer, Source Control Explorer, File List, Project Organizer, Pending Changes window pane), 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 If you have the Content Explorer, Project Organizer or File List open, 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).

    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.