Ravindra BagaleCourses & study guides

Chapter 2: Git Fundamentals

2.3 init, status, add, commit — first repo

Why. You need a local history before you push anywhere.

Tiny example. A hello API folder for badge API with one file app.py (or index.js) that returns a greeting.

Steps — create a repo and first commit

  1. Create a folder and enter it: mkdir badge-api-hello && cd badge-api-hello
  2. Start Git: git init
  3. Create a file (example Python): put a few lines in app.py that print or return "badge API hello"
  4. Ask Git what it sees: git status
  5. Stage the file: git add app.py
  6. Run git status again — the file should appear under Changes to be committed
  7. Save the snapshot: git commit -m "Add badge API hello endpoint stub"
  8. View history: git log --oneline

What you see after git init: a message that an empty repository was initialised (sometimes on branch main or master). After a good commit: git log --oneline shows one line with a short hash and your message.

Configure your name and email once per machine if Git asks (use the email tied to GitHub if you will push later):

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Ravindra Bagale's Tip

Khup students pahila commit -m message shivay kartat aani editor madhe gondhaltat. Suruvatila git commit -m "short message" vapra. Message English madhe, present tense, clear. Dhyan rakho!

Practice task

Without looking, write the order of init, status, add, commit, log and one sentence on what each does.