Backlog uses cookies to deliver our services. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

Now that you understand how to create a git repository, you'll need to know how to save file changes.

It is important to note that Git does not automatically save every change you make. You must tell Git which changes you want to be recorded by staging those changes. After staging, you can commit the changes so that they are recorded in the repo.

Making changes

As we mentioned in the Git workflow section, changes are made in the working tree—a directory consisting of the files you are currently working on. The working tree is where you edit files, add new files, and remove files that are no longer needed.

All files that are changed in the working tree are noted as modified in the index. An index is a staging area where new commits are prepared. It sits between the repository and working tree.

Changes made in the working tree will not be saved directly to the repository. All changes must first be staged in the index in order to be saved in the repo. Only the files in the index are committed to the repo.

Git commit

The git commit command enables you to record file changes in the repository's Git history.

By committing, you will be able to view all changes chronologically in the respective file or directory.

Stored in the repository linked chronologically to each other
The commit history is stored in the local repository.

A 40-character checksum hash is used to uniquely identify a commit. You can use this checksum hash to retrieve the status or changes of files and directories that were made on the given commit in your repository.

Separating different types of changes such as bug fixes, new features, and improvements into different sets of commits will allow you and your team members to easily understand why and how those changes were made.

When committing your changes, you are required to enter a commit message. The commit message should provide descriptive comments regarding the changes you have made.

Write commit messages that are descriptive and easy to understand for all your team members. The following is a recommended structure for an effective Git commit message:

1st line: Abstract of the contents changed by commits
2nd line: Blank line
3rd line and the following lines: Reason for changes

Learn how to commit a file in Git.