| <- Previous: Enable Commit Signing | Next: Learn Remotes And Cloning -> |
|---|
Practice the local Git loop: working directory -> staging area -> commit history.
- explain the difference between the working directory, staging area, and commit history
- create a repository with
git init - stage a file and create a commit
- The working directory is where you edit files.
- The staging area is the set of changes selected for the next commit.
- The commit history is the permanent record stored in
.git. - A commit object stores a snapshot reference, parent reference, author and committer metadata, a message, and optionally a signature.
mkdir first-project
cd first-project
git initecho "Hello Git World! This is my first line of code." > index.txtAt this point, the file exists on disk but is not part of a commit yet.
git status
git add index.txt
git statusAfter git add, the file moves from "untracked" to "staged" in Git's view of the next commit.
git commit -m "feat: add first index file"If signing is configured, Git signs the commit when it creates it.
Run:
git status
git log --oneline -1git statusreports a clean working tree after the commit.git log --oneline -1shows the new commit.- You can explain what
git addchanged beforegit commitwas run.
| <- Previous: Enable Commit Signing | Next: Learn Remotes And Cloning -> |
|---|