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.

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.

Tip

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.

Tip

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