Lesson 1
Git and GitHub setup
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
mainas 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
- Open VS Code.
- Open a new terminal with Ctrl + ` (the key above Tab).
- 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.
git --versiongit version 2.55.0.windows.2Your number may be higher. That is fine. If you see an error, install Git again from Track 0, lesson 3.
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.
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:
git config --global user.nameAsha VermaStep 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.
git config --global user.email "asha.verma@example.com"The command prints nothing. Check it:
git config --global user.emailasha.verma@example.comStep 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:
Initialized empty Git repository in C:/Users/Asha/Documents/test/.git/
On branch masterNow change the setting:
git config --global init.defaultBranch mainThe command prints nothing.
From now on, git init starts on main. You do not need -b main any more.
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.
git config --global --listuser.name=Asha Verma
user.email=asha.verma@example.com
init.defaultbranch=mainGit 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.
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.
- Open github.com/signup (opens in a new tab) in your browser.
- Type your email. Use the same email as in step 3.
- Type a strong password. Save it in a password manager, an app that keeps your passwords safe.
- Type a username. See the tips below.
- Choose your country, then click Continue or Create account.
- Solve the small puzzle that checks you are a person.
- Open your inbox. Copy the code GitHub sent you.
- Paste the code on the GitHub page.
- 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-vermaorashaverma-dev. - Use only letters, numbers and single dashes.
- Avoid jokes, birth years and words like
coolorking. - Keep it short. You will type it often.
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.
- Click your profile picture in the top right corner on github.com.
- Click Settings.
- In the Access part of the left menu, click Emails.
- Tick Keep my email addresses private.
- Copy the address that ends in
users.noreply.github.com. - Run the email command again with that address.
git config --global user.email "12345678+asha-verma@users.noreply.github.com"Use your own address. The number is different for every person.
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.
- Look at the bottom of the thin bar on the far left of VS Code. Find the Accounts icon. It looks like a person.
- Click it.
- If you see an item that starts with Sign in with GitHub, click it.
- Click Allow if VS Code asks to use GitHub.
- Your browser opens. Sign in to GitHub if asked.
- Click the green button to authorize VS Code.
- 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.
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).
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.
git config --global core.editor "code --wait"The command prints nothing.
--wait makes Git wait until you close the VS Code tab.
git config --global core.editor prints code --wait.Output
When every step works, you have:
- Git that prints its version.
- Your name, email and
mainingit 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
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:
- Close VS Code fully, then open it again.
- Run
git --versionagain. - 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.
git config --global user.nameAshaFix: 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.
fatal: unable to read config file 'C:/Users/Asha/.gitconfig': No such file or directoryWhy: 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
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 disabledWhy: 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:
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 insidechai-corner, because that is already a Git project. - Make a new folder called
git-testwithmkdir, then move into it withcd. - Run
git init. Do not add-b main. - Make a file called
notes.txtwith any text. - Add it and commit it with the message
First test commit. - Run
git logand read theAuthorline.
Expected result: git init puts you on main. The commit is on main. The author line shows your name and email.
Show solution
cd ~
mkdir git-test
cd git-test
git init
Set-Content notes.txt "hello"
git add .
git commit -m "First test commit"
git logInitialized 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 commitmkdir 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.
[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.nameanduser.emailsign 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 mainmakes new projects start onmain.git config --global --listshows 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.