Skip to content

How do I track changes to my file?

In Git, you don’t save a changed file - instead, you track the changes made to it. This allows you to always see what was modified at any point in time and, if necessary, revert to a previous version. File changes can be made either directly in the web browser or locally on your computer. Working locally is useful if you prefer working in your familiar development environment, especially when writing and running code. In this tutorial, we will start with editing a text file using the web browser, so you won’t need to write any code - you can simply use the appropriate buttons.

To modify a file in the web browser, start by opening the repository and clicking on the file you’ve added for tracking changes. At the top-right corner you will see a small pencil icon ✏️ labeled Edit this file. By clicking on it, a text editor window will open, where you can begin making changes.

It is a common best practice to always write only one sentence per line. This makes it easier for reviewers to provide feedback, but there are also other good reasons to follow this approach.

Everyone is familiar with saving a file after is has been modified. In Git, however, you don’t simply save the file - instead, you commit the changes to track what was modified.

To commit a change after you have modified the file, you can use the button Commit Changes in the web browser. Clicking on it will open a dialogue window with different fields to fill:

  • Commit message: Give a name to your changes - later you will be able to search for them.
  • Extended description: If needed, give more detailed information.
  • Commit directly to the any name branch: For now choose this.
  • Create a new branch for this commit and start a pull request: Branching out will be described further down.
  • Agree by clicking on Commit changes again.

In Git, you can view all kinds of changes - whether for a single file, the entire repository, or even across the full network of repositories.

  1. To check the history of the file you just modified, open that file in your repository. At the top-right corner, above the edit button, you will find a clock icon labeled 🕓History. Clicking it will open the history of commits, showing the commit message, the author of the commit and the SHA, which is a unique identifier for each commit within Git.
  2. To see the history of all changes in the repository you are currently working on, go to the repository’s main page. Under the green Code button, you will find another one, labeled 🕓Commits, followed by the number of commits made to the current branch. By clicking this you can see the same information as in the history of a file, but for all the files of the repository.
  3. There is the possibility to see all kinds of statistics about the repository in the Tab 📈Insights. There you will find an overview, with lots of further options on the left-hand side menu. For example, under Network you can see the timeline of the most recent commits to the repository, including branches and forks - which are described later in this tutorial.