1. Git and GitHub setup

Aap kis language mein padhna chahoge?

Which language do you want to learn in?

Code aur technical words English mein hi rahenge. Aap baad mein bhi language badal sakte ho.

Lesson 1

Git and GitHub setup

Beginner 40 minutes

You need before starting

  • Track 0, lesson 1, VS Code installed
  • Track 0, lesson 3, Git installed and your first commits
  • An email address you can open

What you will learn

  • Check that Git works on your computer.
  • Tell Git your name and email, and why it needs them.
  • Make Git name your first branch main.
  • Create a GitHub account with a good username.
  • Sign in to GitHub from VS Code.
  • Know what happens the first time you send code to GitHub.

What it is

Git and GitHub

You met Git in Track 0. It saves the history of your project on your computer.

GitHub is a website that keeps a copy of your Git projects online. Think of Git as your notebook at home. GitHub is a safe locker in the city where you keep a copy of that notebook. If your laptop breaks, the copy in the locker is still there.

Git and GitHub are two different things. Git is a program. GitHub is a website that understands Git.

Git config

Git config means Git settings. You change them with the command git config. It is like the settings page of your phone. You set it once, and it is used everywhere.

Global

--global means "for every project on this computer". Git saves these settings in a file named .gitconfig in your user folder. You never need to open that file. The commands do it for you.

Default branch

A branch is one line of saved history. You met it in Track 0. The default branch is the name Git gives the first branch in a new project. Today almost everyone uses the name main. GitHub uses main too.

Account and username

A GitHub account is your profile on GitHub. Your username is your public name there, like asha-verma. It becomes part of every project address, like github.com/asha-verma/chai-corner. Clients and employers will see it. So pick it like an email address for work.

Sign in and credentials

Credentials are the proof of who you are, like a key to your locker. GitHub needs this proof before it lets you put code in your locker.

Why you need it

  • Every commit carries your name and email. Without them, Git refuses to commit.
  • GitHub links commits to your account by the email. Then they count on your profile.
  • With main as the default, your projects match GitHub from day one.
  • Every job and client project you join will use GitHub, or a site like it.
  • Setting this up once saves you from strange errors later.

Before you start

  1. Open VS Code.
  2. Open a new terminal with Ctrl + ` (the key above Tab).
  3. Keep your email inbox open in your browser. GitHub will send you a code.

You can run every command from any folder. These settings are for the whole computer.

Steps

Step 1: Check that Git works

What it does: prints the Git version. When you use it: on a new computer, or when something feels broken. Why: it proves Git is installed and VS Code can find it.

PowerShell
git --version
Output
git version 2.55.0.windows.2

Your number may be higher. That is fine. If you see an error, install Git again from Track 0, lesson 3.

Check: The output starts with git version.

Step 2: Tell Git your name

What it does: saves your name in the global settings. When you use it: once, on each new computer. Why: Git signs every commit with this name. Your team sees it in the history.

PowerShell
git config --global user.name "Asha Verma"

Use your own real name. Keep the quotes, because a name has a space in it. The command prints nothing when it works.

Read it back to check:

PowerShell
git config --global user.name
Output
Asha Verma
Check: The command prints your full name.

Step 3: Tell Git your email

What it does: saves your email in the global settings. When you use it: once, on each new computer. Why: every commit carries this email. GitHub uses it to link the commit to your account.

Think of a letter with a return address. GitHub reads the return address and puts the letter in your profile. If the email does not match your GitHub account, the commit still works. But it does not show your photo, and it does not count on your profile.

Use the same email you will use for GitHub.

PowerShell
git config --global user.email "asha.verma@example.com"

The command prints nothing. Check it:

PowerShell
git config --global user.email
Output
asha.verma@example.com
Check: The command prints your email.

Step 4: Name your first branch main

What it does: tells git init to call the first branch main. When you use it: once, on each new computer. Why: Git for Windows calls the first branch master unless you change it. GitHub calls it main. Two different names cause confusion later.

Here is what git init and then git status print in a new folder, before this setting:

Output
Initialized empty Git repository in C:/Users/Asha/Documents/test/.git/
On branch master

Now change the setting:

PowerShell
git config --global init.defaultBranch main

The command prints nothing. From now on, git init starts on main. You do not need -b main any more.

Check: git config --global init.defaultBranch prints main.

Step 5: See all your settings

What it does: lists every global setting. When you use it: any time you want to check your setup. Why: one command shows that steps 2, 3 and 4 all worked.

PowerShell
git config --global --list
Output
user.name=Asha Verma
user.email=asha.verma@example.com
init.defaultbranch=main

Git prints setting names in small letters, so you see defaultbranch. That is normal. You may see extra lines if you set other things before. That is fine too. If the list is long, press Q to leave it.

Check: The list has your name, your email, and init.defaultbranch=main.

Step 6: Create a GitHub account

GitHub is free for students and small projects.

Did you make a GitHub account in the Track 0 final project? Then skip this step. Sign in, and check that your email is verified under Settings, then Emails.

  1. Open github.com/signup (opens in a new tab) in your browser.
  2. Type your email. Use the same email as in step 3.
  3. Type a strong password. Save it in a password manager, an app that keeps your passwords safe.
  4. Type a username. See the tips below.
  5. Choose your country, then click Continue or Create account.
  6. Solve the small puzzle that checks you are a person.
  7. Open your inbox. Copy the code GitHub sent you.
  8. Paste the code on the GitHub page.
  9. Answer or skip the welcome questions.

GitHub may change the order of these screens. Follow the prompts on the page. You can also sign up with Google or Apple. Then you still choose a username.

Good username tips:

  • Use your real name, like asha-verma or ashaverma-dev.
  • Use only letters, numbers and single dashes.
  • Avoid jokes, birth years and words like cool or king.
  • Keep it short. You will type it often.
Check: You are signed in on github.com and you see your username when you click your profile picture (top right).

Step 7 (optional): Use your private GitHub email

GitHub can give you a private email for commits. It looks like 12345678+asha-verma@users.noreply.github.com. Commits with it still link to your account. Your real email stays hidden.

  1. Click your profile picture in the top right corner on github.com.
  2. Click Settings.
  3. In the Access part of the left menu, click Emails.
  4. Tick Keep my email addresses private.
  5. Copy the address that ends in users.noreply.github.com.
  6. Run the email command again with that address.
PowerShell
git config --global user.email "12345678+asha-verma@users.noreply.github.com"

Use your own address. The number is different for every person.

Check: git config --global user.email prints the address that ends in users.noreply.github.com.

Step 8: Sign in to GitHub inside VS Code

VS Code can talk to GitHub for you. It needs your permission once.

  1. Look at the bottom of the thin bar on the far left of VS Code. Find the Accounts icon. It looks like a person.
  2. Click it.
  3. If you see an item that starts with Sign in with GitHub, click it.
  4. Click Allow if VS Code asks to use GitHub.
  5. Your browser opens. Sign in to GitHub if asked.
  6. Click the green button to authorize VS Code.
  7. Allow the browser to open VS Code again.

If no sign-in item is there, that is fine. VS Code asks you to sign in by itself the first time you send code to GitHub. You will do that in the next lesson.

Check: Click the Accounts icon again. You see your GitHub username in the menu, or you plan to sign in at your first push.

Step 9: Know what happens at your first push

To push means to send your commits to GitHub. You learn it in the next lesson. Here you only need to know what to expect.

The first time you push from the terminal, a window opens. It is Git Credential Manager. It comes inside Git for Windows. It asks you to sign in to GitHub in the browser. After that, Windows remembers you. You do not sign in again on this computer. Did you push chai-corner in the Track 0 final project? Then you already did this sign-in.

On a Mac or Linux, the first push may ask for a username and password in the terminal. Type your username. For the password, paste a personal access token, not your GitHub password. GitHub explains this in About remote repositories (opens in a new tab).

Check: You can explain your first push in one sentence: a browser sign-in opens, and you never type your password.

Step 10: Make VS Code your Git editor

What it does: tells Git to open VS Code when it needs you to write or check a message. When you use it: once, on each new computer. Why: some Git commands, like a merge, open an editor. Without this setting, Git for Windows opens Vim in the terminal. Vim is hard to close if you have never used it.

PowerShell
git config --global core.editor "code --wait"

The command prints nothing. --wait makes Git wait until you close the VS Code tab.

Check: git config --global core.editor prints code --wait.

Output

When every step works, you have:

  • Git that prints its version.
  • Your name, email and main in git config --global --list.
  • A GitHub account with a verified email and a clean username.
  • VS Code signed in to GitHub, or ready to sign in at your first push.
  • VS Code as the editor Git opens for messages.

Common errors

git is not recognized

Output
git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.

Why: Git is not installed, or VS Code was open while you installed it.

Fix:

  1. Close VS Code fully, then open it again.
  2. Run git --version again.
  3. If it still fails, install Git from Track 0, lesson 3.

Only your first name was saved

You typed git config --global user.name Asha Verma without quotes. Git prints no error. But it saves only the first word.

PowerShell
git config --global user.name
Output
Asha

Fix: Run the command again with quotes: git config --global user.name "Asha Verma".

unable to read config file

You ran git config --global --list before any other setting.

Output
fatal: unable to read config file 'C:/Users/Asha/.gitconfig': No such file or directory

Why: the settings file does not exist yet. Git makes it at your first git config --global command.

Fix: Do steps 2, 3 and 4. Then run --list again.

Author identity unknown

Output
Author identity unknown

*** Please tell me who you are.

Run

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

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: no email was given and auto-detection is disabled

Why: you skipped step 2 or step 3 on this computer.

Fix: Do steps 2 and 3. Then run your git commit again.

Commits do not show on your GitHub profile

Why: the email in git config is not an email on your GitHub account.

Fix: Set user.email to your GitHub email or your private noreply email (step 7). New commits will link to you. Old commits keep the old email.

Password authentication was removed

You typed your GitHub password when a terminal asked for one. GitHub answers like this:

Output
remote: Support for password authentication was removed on August 13, 2021.
fatal: Authentication failed for 'https://github.com/your-username/chai-corner.git/'

Fix: Use the browser sign-in window, or paste a personal access token instead of the password.

Try it yourself

Practice task

Task: Prove your setup works. Make a test project, make one commit, and read the author line.

Hints:

  • First run cd ~ to go to your home folder. Do not make the test inside chai-corner, because that is already a Git project.
  • Make a new folder called git-test with mkdir, then move into it with cd.
  • Run git init. Do not add -b main.
  • Make a file called notes.txt with any text.
  • Add it and commit it with the message First test commit.
  • Run git log and read the Author line.

Expected result: git init puts you on main. The commit is on main. The author line shows your name and email.

Show solution
PowerShell
cd ~
mkdir git-test
cd git-test
git init
Set-Content notes.txt "hello"
git add .
git commit -m "First test commit"
git log
Output
Initialized empty Git repository in C:/Users/Asha/git-test/.git/
[main (root-commit) e12b207] First test commit
 1 file changed, 1 insertion(+)
 create mode 100644 notes.txt
commit e12b207063571dbf4a8bb38dfec1cf56faf1d96f
Author: Asha Verma <asha.verma@example.com>
Date:   Wed Oct 7 13:33:19 2026 +0530

    First test commit

mkdir also prints a small table in PowerShell. You can ignore it. Your path, ID and date will be different. When you are done, you can delete the git-test folder.

Check: The commit line says [main (root-commit), and the Author line shows your own name and email.

Quick recap

  • Git keeps history on your computer. GitHub keeps a copy online, like a locker.
  • git config --global user.name and user.email sign every commit. Use quotes for the name.
  • Use your GitHub email, or the private noreply email, so commits count on your profile.
  • git config --global init.defaultBranch main makes new projects start on main.
  • git config --global --list shows all your settings.
  • Pick a clean, professional GitHub username and verify your email.
  • Your first push opens a browser sign-in. Your GitHub password never works for Git.
  • git config --global core.editor "code --wait" makes Git open messages in VS Code.