Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 1.83 KB

File metadata and controls

71 lines (52 loc) · 1.83 KB

🚀 Make Your First Commit


<- Previous: Enable Commit Signing Next: Learn Remotes And Cloning ->

🎯 Outcome

Practice the local Git loop: working directory -> staging area -> commit history.

✅ You Should Be Able To

  • 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

🧠 Key Ideas

  • 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.

1️⃣ Create A Repository

mkdir first-project
cd first-project
git init

2️⃣ Create A File In The Working Directory

echo "Hello Git World! This is my first line of code." > index.txt

At this point, the file exists on disk but is not part of a commit yet.

3️⃣ Stage The File

git status
git add index.txt
git status

After git add, the file moves from "untracked" to "staged" in Git's view of the next commit.

4️⃣ Create The Commit

git commit -m "feat: add first index file"

If signing is configured, Git signs the commit when it creates it.

🧪 Verify

Run:

git status
git log --oneline -1

🏁 Success Criteria

  • git status reports a clean working tree after the commit.
  • git log --oneline -1 shows the new commit.
  • You can explain what git add changed before git commit was run.

<- Previous: Enable Commit Signing Next: Learn Remotes And Cloning ->