Tuesday, December 16, 2014

Discarding changes to a file in SourceTree

There are situations in which you have a work in progress code, which you do not want to commit, but want to roll back changes for the previous commit state, Git helps us achieve this using the Discard option.

         When you discard changes in the working / staging area the changes are removed and            the working copy is rolled back to the previous commit state. Discarding changes can be            done as follows.


1.    Opens the Source Tree application
          2. Select the Discard option from the toolbar

3.    In the pop-up which appears, you can see the list of files with the changes in the files which will get discarded.

4.    You can compare the changes, select the files whose changes needs to be discarded and click on the ‘Discard Changes’ button.
5.    This will roll back changes made to the selected files and restores them to the previous commit state.
6.    The physical files in the disk are also modified to reflect the previous commit state.
7.    Unlike Stashing which provides an option to restore the state, the changes done using the Discard option cannot be restored hence you need to be careful before discarding changes as there is no way to get the changes back.

Search Flipkart Products:
Flipkart.com

No comments: