Git Regular Workflow – Edit & Commit
The goal of this chapter is to master the basic cycle of editing and saving code (creating version histories) with key Git commands.
There are 8 key Git commands you will learn in this chapter.
git add
: with this command, you can add files to the Staging Area (INDEX), where you can prepare and check files to register in your Local Repository.git status
: with this command, you can check the status of the Working Tree (working directory) and the Staging Area (INDEX). This status lets you see which changes have been staged, which haven't, and which files aren't tracked by Git.git commit
: with this command, you can register files in your Local Repository. Once the files are registered by this command, you can retrieve the saved version of the set of files anytime.git log
: with this command, you can check the information of the commit history.git diff
: with this command, you can check the differences between the Working Tree, Staging Area (INDEX), and Commits.git restore
: with this command, you can bring your Working Tree back to the latest commit or a specific commit. This command is useful when you want to clear your edits and go back to a cleaner version.git rm
: with this command, you can delete files or directories under the Working Tree and the Staging Area (INDEX). When you want to reflect the deleted status as one of the versions, you need to create another commit.git reset
: with this command, you can reset the Staging Area (INDEX) or change commit histories with or without changing the content of your local files.