Git records a project’s change history. Use a new practice folder for this exercise. Install Git and create a plain text file named README.md.
Create a repository
init creates the repository. The name and email below apply only to this repository. Replace them with your chosen identity for real work.
git init
git config user.name "Demo Learner"
git config user.email "learner@example.test"
git statusRecord your first version
Use add to stage README.md, then commit to record the version. Staging selects which changes will enter the next commit. Saving a file in your editor is not a commit.
git add README.md
git commit -m "Add project introduction"
git log --onelineCreate a branch
The next command creates and switches to a new branch. Add a line to README and inspect the difference. Use add and commit again to record that change. This exercise does not create a remote repository.
git switch -c learning-notes
git diff
git statusCheck your understanding
Does git add publish the project, stage changes for a commit, or erase history?
It stages the selected changes for a future commit.