Skip to content

How to track changes to my file?

With Git, you don’t just save a modified file - instead, Git tracks the history of your file’s modifications over time. 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 have added. At the top-right corner you will see an edit button. It might be labeled Edit or have a small pencil icon ✏️. 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 it 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 at the top-right corner 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 current branch or create a new branch for this commit and start a pull request: Branching out will be described later.

After committing, the changes will become part of the repository history.

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 view the history of changes for your current branch, go to the repository’s main page. Below the green Code button, you will find another one, labeled 🕓 Commits, including the number of commits. This displays a list of all commits made to the current branch. Each commit in this list represents a snapshot of the repository at that time; clicking on a specific commit shows you the exact changes made to all files in that snapshot. You can view the history of commits for another branch by selecting one from the branch dropdown button at the top-left corner of the page.

  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.