Undoing Changes
If you have discovered that you have made a mistake, theBranch makes it easy to undo changes and revert to a known good state.
If you have not yet made a commit
If you have yet to make a commit, you can undo changes to individual files, or the entire repository, and bring the files (or repository) back to the state it was in after the last commit.
Discarding changes in an individual file
Press the Commit button on the toolbar, or select Commit CTRLENTER from the menu. On a Mac, go to Tree > Commit.
The Commit dialog will appear.
Locate the file that you want to roll back. Follow the steps below depending on what letter appears next to it:
N
Right click on the file and select Delete from Repository. theBranch will delete the file on disk.dangerOnce the file has been deleted, it is not recoverable, as it has not been committed.
Anything Else
Right click on the file and select Discard Changes. theBranch will replace the file with the version of the file as at the last commit.dangerOnce the changes have been discarded, they are not recoverable, as they have not been committed.
Discarding changes in the repository
Select Discard All Changes from the menu. On a Mac, go to Tree > Discard All Changes.
You will be asked to confirm that you want to discard all the changes in the repository.
If you are sure that you want to discard all the changes since the last commit, click Discard Changes. theBranch will replace all files under source control with the version as at the last commit.
If you also check Also delete untracked files, theBranch will also delete any files that have not yet been committed.
Once the changes have been discarded, they are not recoverable, as they have not been committed.
If you have made a commit, but have not pushed it
To return the repository to an earlier state, use the Reset function.
Do not reset to before a commit that you have pushed. The repository will become out of sync with the remote, and you will need to pull, re-introducing the commits that you reset away.
To reset the repository to an earlier state, in the tree, select the branch that contains the commit, locate the commit and right click on it. Select Reset.
Choose from the following reset methods:
- Hard Reset
This will reset the repository and also the files on disk to reflect the commit that you select. Any commits after the commit you select will be discarded.dangerA hard reset has the potential to delete any pending changes. Once these changes are deleted, they will not be recoverable, as they have not been committed.
- Mixed Reset
This will reset the repository, but will leave the files on disk intact. The index will be merged with the contents of the commit. Any commits after the commit you select will be discarded. - Soft Reset
This will reset the repository, but will leave the files on disk intact. Any commits after the commit you select will be discarded.
If you have already pushed a commit
Use the Revert function. Reverting a commit creates a new commit that undoes all the changes introduced in a single commit.
If you want to undo multiple commits, you will need to revert each commit one by one, in reverse chronological order.
To undo the changes introduced in a commit, in the tree, select the branch that contains the commit, locate the commit and right click on it. Select Revert.
To revert the commit, click Revert. theBranch will revert the files and create a revert commit.
If you are reverting a merge commit, you will be asked to select a mainline commit. The changes from this commit, along with any merge resolution will be undone.
Resolving conflicts
If changes from the commit conflict with the current files, Git will not be able to merge the changes automatically. For example, if the same line is changed in your local repository (in a later commit) and also in the commit to be reverted, a conflict occurs. If this happens when you are reverting, you will be asked to resolve conflicts.
Once you have selected an appropriate resolution for all the conflicting changes, click Revert. theBranch will conclude the revert operation, resolving the conflicting changes in the manner that you instructed.