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.
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.
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.
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.
No comments:
Post a Comment