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
- Create a folder and enter it:
mkdir badge-api-hello && cd badge-api-hello - Start Git:
git init - Create a file (example Python): put a few lines in
app.pythat print or return"badge API hello" - Ask Git what it sees:
git status - Stage the file:
git add app.py - Run
git statusagain — the file should appear under Changes to be committed - Save the snapshot:
git commit -m "Add badge API hello endpoint stub" - 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.