Code / Command Line & Git / Unit 3: Git basics: save every version

Why version control? Version control क्यों?

Lesson 6 of 12 · about 12 minutes · What git does, git config, git init and git status.

⚡ 0 XP

Step 1 of 2

final_v2_REALLY_final.txt

Add menua1f3Add prices7c2eFix typo9b04HEAD→main

Ever saved project-final.docx, then project-final-2.docx, then project-REALLY-final.docx? Version control fixes that mess.

Git takes a snapshot of your whole project whenever you say so. Each snapshot is a commit, with a message like "Add winter menu". You can look back at any commit, see exactly what changed, and undo mistakes.

  • Teams use git so many people can work on the same code without overwriting each other.
  • GitHub is a website where git projects (repos) are shared online. In this course we stay offline, but every command you learn is exactly what you will use with GitHub later.

First, tell git who you are, so your commits carry your name: git config user.name "Asha Rao". Then git init turns a folder into a repository (repo), and git status tells you what is going on.

Example
git config user.name "Asha Rao"
mkdir diary
cd diary
git init
git status
ls -a
terminalCtrl ⏎
asha@indiadigital:~$ git config user.name "Asha Rao"
asha@indiadigital:~$ mkdir diary
asha@indiadigital:~$ cd diary
asha@indiadigital:~/diary$ git init
Initialized empty Git repository in /home/asha/diary/.git/
asha@indiadigital:~/diary (main)$ git status
On branch main
 
No commits yet
 
nothing to commit (create/copy files and use "git add" to track)
asha@indiadigital:~/diary (main)$ ls -a
./ ../ .git/
Files · ~ = /home/asha
  • diary/ ← you are here
Git timeline

Repository ready — no commits yet. (main)

Lesson notes (text version)

1. final_v2_REALLY_final.txt

Ever saved project-final.docx, then project-final-2.docx, then project-REALLY-final.docx? Version control fixes that mess.

Git takes a snapshot of your whole project whenever you say so. Each snapshot is a commit, with a message like "Add winter menu". You can look back at any commit, see exactly what changed, and undo mistakes.

  • Teams use git so many people can work on the same code without overwriting each other.
  • GitHub is a website where git projects (repos) are shared online. In this course we stay offline, but every command you learn is exactly what you will use with GitHub later.

First, tell git who you are, so your commits carry your name: git config user.name "Asha Rao". Then git init turns a folder into a repository (repo), and git status tells you what is going on.

                git config user.name "Asha Rao"
mkdir diary
cd diary
git init
git status
ls -a
              

2. git init and git status

git init creates a hidden .git folder — that is where git keeps all the snapshots. You never edit it by hand.

git status is your best friend. Run it often! It tells you which branch you are on, which files are new (untracked), changed, or ready to commit.

On a real computer, use git config --global user.name "Your Name" once, and git remembers it for every project.

Challenge: Start the chai-site repo

Set your name with git config user.name "…" (any name you like). Then make a folder chai-site, go into it, turn it into a repo with git init, and run git status.

Search by task, format or tool name.