π Practice: Git Commands
In the previous lesson, we initialized git in our project and walked through the status lifecycle of files. That was a lengthy walkthrough so let's now practice the most relevant points.
When you make changes in your project, you have the option to make a commit which will preserve a snapshot of your project at that moment. The steps are:
Make a change in your project. Such as, add a new line of code or delete lines of code.
Add those changes to be committed using:
git add name-of-file- Additionally, you can include multiple file names in the
git addcommand. Separate file names using a space. git add .adds all modified files without having to name all files.
- Additionally, you can include multiple file names in the
Commit staged changes using:
git commit -m βbrief messageβRepeat these steps as necessary. Recommend using
git statusafter every step to check file status as you are learning. Usegit diffoften to see changes of modified files. Usegit logto view your commit history.
For this practice lesson, the goal is to start building good muscle memory. These git commands are the ones you will use most frequently in your workflow. Make a commit for every minor change and commit messages should be a single sentence description of the change.