PyCharm Edu allows you to trace back all changes in your project so that you can locate the author of changes, review the differences between different file versions, and safely roll back and undo changes if necessary.
Review project history
PyCharm Edu allows you to review all changes made to the project sources that match the specified filters. To view project history, open the Version Control tool window (Alt+9) and switch to the Log tab. It shows all changes committed to all branches and remote repositories:
Use the search field to search through the list of commits by entering full commit names or messages or their fragments, revision numbers, or regular expressions. You can also filter the commits by branch, user, date and folder (or root and folder for multi-root projects).
You can also click the Go to Hash/Branch/Tag icon on the toolbar or press Ctrl+F and specify a commit hash, tag or the name of a branch you want to jump to (you will be taken to the latest commit in that branch).
Note that clicking an arrow takes you to the next commit in a long branch:
In multi-repository projects, the colored stripe on the left indicates which root the selected commit belongs to (each root is marked with its own color). Hover the mouse cursor over the colored stripe to invoke a tip that shows the root path:
For more details on the project Log view, see Log Tab.
Review file history
If you need to review all changes made to a specific file, and identify what exactly was modified in each revision, do the following:
- Select the required file in any view (in the Project tool window, in the editor, in the Local Changes tab of the Version Control tool window, etc.).
- Select Git | Show History from the main VCS menu or from the context menu of the selection. The History tab is added to the Version Control tool window showing the history for the selected file and allowing you to review and compare its revisions.
- To identify which changes were introduced in a specific revision, select it in the list and press Ctrl+D or click the button on the toolbar. The Differences Viewer will open showing what has changed in this file revision:
Review the differences between the local and a committed version
If you need to check how a committed file revision is different from its local version, do the following:
- Open the Version Control tool window (Alt+9) and switch to the Log tab.
- Select the commit you are interested in, and in the right pane select the file in question.
- Click the button on the toolbar.
Review how changes were merged
In the Log view, select the merge commit you are interested in:
- If no conflicts were detected and resolved during the merge, PyCharm Edu will display the corresponding message in the Changed Files pane, and will suggest you to review changes originating from both parents:
Select the required file from one of the nodes and click the Show Diff icon on the toolbar or press Ctrl+D. The Differences Viewer will show a two-panel diff allowing you to compare the current version with the selected parent.
- If conflicts occurred during the merge, the Changed Files pane will show you a list of files merged with conflicts.
Select the required file and Show Diff icon on the toolbar or press Ctrl+D. The Differences Viewer will show a three-panel diff allowing you to compare the current version with each of its parents, and see how exactly conflicts were resolved.
Locate code author (annotate/blame)
PyCharm Edu allows you to figure out who introduced which changes to a file by using annotations. Annotation is a form of file presentation that shows detailed information for each line of code, including the revision from which this file originated, the user ID of the person who committed this line, and the commit date. The annotated view helps you find out who did what and when, and trace back the changes.
You can get the annotated view of a file opened in the editor, in the Differences Viewer, or selected in any tool window. The Annotate command is available from the context menu (Git | Annotate) or from the left gutter context menu of the editor or the Differences Viewer.
When annotations are enabled, the left gutter looks similar to the following example:
Annotations for lines modified in the current revision, are marked with bold type and an asterisk.
You can configure the amount of information displayed in the annotations view by right-clicking the annotations gutter and selecting View from the context menu.
Annotate a previous revision
PyCharm Edu lets you annotate not only the current file revision, but also its previous revisions. The following options are available from the context menu of the annotations gutter:
- Annotate Revision: this option is useful if you want to check what a file looked like after a particular change was committed.
- Annotate Previous Revision: this option is useful if you find yourself in a situation when the last change in a particular line is meaningless, for example if all that was changed is code formatting. In this case, you can check what the previous revision of the file looked like.
You can also annotate a particular file from the History view. In the History tab, select the file version you want to review, right-click the corresponding line and select Annotate from the context menu.
Watch this video to learn more on how you can benefit from using annotations: