Git Setup in VS Code: Install, Config & Push to GitHub
Learn how to set up Git in VS Code step by step: install Git, run git config user.name and user.email, install Git Graph, clone a repo and push to GitHub.
This guide shows you how to do a git setup in VS Code from zero. By the end you will have Git installed, a GitHub account, your name and email saved with git config, a repository cloned to your computer, and your first code pushed to GitHub. Every step is short. Do them in order, and check the "You should see" box at the end of each step before you move on. Total time: about 20 minutes.
What you need before you start
- A computer with internet (the steps use Windows; macOS and Linux commands are included)
- An email address you can open
- Visual Studio Code. Get it free from code.visualstudio.com
The 7 Steps

Steps 1 to 4 are one-time setup. Steps 5 to 7 are what you repeat for every new project.
Step 1: Download and Install Git
Goal: put Git on your computer. VS Code does not include Git, so this comes first.
1.1 Download Git
- Go to git-scm.com/install. Stay on the Windows tab.
- Click `
Click here to download`. This gives you the latest 64-bit installer. (On an ARM laptop, choose Git for Windows/ARM64 Setup instead.)

1.2 Install Git
- Open the downloaded file (for example, Git-2.56.1-64-bit.exe) and click Next.
- When choosing the default editor, pick Visual Studio Code.
- On Adjusting the name of the initial branch, choose Override the default branch name and type main.
- Click Next on every other screen. The defaults are correct, including Git Credential Manager, which handles your GitHub sign-in later.
- Click Install, then Finish.
1.3 Other ways to install (optional)
# Windows (PowerShell or Command Prompt)
winget install --id Git.Git -e --source winget
# macOS
brew install git
# Ubuntu / Debian
sudo apt update && sudo apt install git
1.4 Check that Git works
Open Git Bash (search for it in the Start menu), or any new terminal, and type:
git --version
YOU SHOULD SEE A version number, such as git version 2.56.1.windows.1. If you see "not recognized", close the terminal, open a new one and try again.
Step 2: Create a Free GitHub Account
Goal: get an online home for your code. Git works on your computer; GitHub stores your projects on the web.
- Go to github.com/signup.
- Click Continue with Google or Continue with Apple, or fill in the form: Email, Password, Username.
- Password rule: at least 15 characters, or at least 8 with a number and a lowercase letter.
- Username rule: letters, numbers and single hyphens only. It will be public and appear in your repository links.
- Pick your country, then click Create account. Solve the puzzle and type the code GitHub emails you.

YOU SHOULD SEE You are logged in to github.com with your new username at the top right.
Step 3: Set Your Git Username and Email (git config)
Goal: tell Git who you are. Git adds your name and email to every commit. If you skip this, your first commit fails with "Author identity unknown".
3.1 Run the git config commands
Open Git Bash, Command Prompt or PowerShell. This works the same in every one of them. Run these two lines, using your own name and the email on your GitHub account:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
--global means "save this for my whole computer", so you only do this once.
3.2 Check your git config
git config user.name
git config
# or show everything at once
git config --list
YOU SHOULD SEE Your name and email printed back to you, exactly as you typed them
GOOD TO KNOW These two settings only label your commits. They are not your GitHub login. You will sign in to GitHub in Step 7. To keep your real email private, use the no-reply address shown in GitHub Settings, then Emails.
Want a different name or email for just one project? Run the same command without --global inside that project folder. Git uses the most specific level that exists:

Step 4: Install the Git Graph Extension in VS Code
Goal: add a visual map of your commits and branches to VS Code. Install it now, because Step 7 uses it to show your first commit. (Skip it only if you plan to use the terminal-only path in Steps 6 and 7.)
- Open VS Code.
- Click the Extensions icon in the left bar (or press Ctrl + Shift + X).
- Type git graph in the search box.
- Choose Git Graph by mhutchie. Ignore similar names from other publishers.
- Click the blue Install button. Wait a few seconds until it changes to Uninstall or Disable.

YOU SHOULD SEE Git Graph by mhutchie listed as installed, with Disable and Uninstall buttons. The graph itself appears only after you open a repository in Step 6.
Step 5: Create a New Repository on GitHub
Goal: make an empty project folder on GitHub. A repository (repo) holds your files and their history.
- On github.com, click the + at the top right, then New repository.
- Repository name: type a short name with no spaces, such as myportfolio.
- Visibility: choose Public (anyone can see it) or Private (only you).
- Add README: switch it On. This puts a first file in your repo.
- Leave .gitignore and license as they are for now.
- Click Create repository.

YOU SHOULD SEE Your new repository page, showing a README.md file.
Step 6: Clone the Repository to Your Computer
Goal: download your repo to your PC and link it to GitHub. "Clone" means "make a connected copy".
CHOOSE YOUR PATH FOR STEPS 6 AND 7 Path A: VS Code buttons. Uses the Command Palette and the Source Control panel, which are built into VS Code. Git Graph (Step 4) is used only at the very end to see your history. Path B: Terminal only. Uses typed commands and needs no extension at all. Both paths give the same result, so pick one and stay with it.
6.1 Copy the clone link (both paths)
- On your repository page, click the green Code button.
- Make sure the HTTPS tab is selected.
- Click the copy icon next to the link.

6.2 Path A: Clone with VS Code
- In VS Code, press Ctrl + Shift + P to open the Command Palette.
- Type Git: Clone and press Enter.
- Paste the link and press Enter.
- Choose a folder on your computer to save it in, such as C:\Projects.
- When VS Code asks, click Open.
6.2 Path B: Clone with the terminal only
- Open a terminal: Git Bash, Command Prompt, PowerShell, or inside VS Code press Ctrl + `.
- Go to the folder where you want your projects, then run the clone command with your own link.
- Move into the new folder and open it in VS Code.
cd C:\Projects
git clone
cd myportfolio
code .
YOU SHOULD SEE Your project folder open in VS Code, with README.md in the Explorer on the left. For a public repo no login is needed yet.
Step 7: Commit and Push Your First Code (and Sign In)
Goal: send your first change to GitHub. This is also where you sign in, because GitHub only asks for authentication the first time you push.
Git moves code through four places. You will do the first three arrows now. Each part below shows Path A (VS Code) and Path B (terminal).

Before Path B, open the terminal inside your project folder. In VS Code press Ctrl + `. It opens in the right folder automatically.
7.1 Make a change
Path A (VS Code): click New File in the Explorer, name it index.html, paste this, then press Ctrl + S:
<!DOCTYPE html>
<html>
<body>
<h1>Hello, Git!</h1>
</body>
</html>
Path B (terminal): create the same kind of file with one command.
# Git Bash, macOS, Linux
echo "<h1>Hello, Git!</h1>" > index.html
# Windows PowerShell
Set-Content index.html "<h1>Hello, Git!</h1>"
7.2 Commit the change (save a snapshot)
Path A (VS Code):
- Click the Source Control icon in the left bar (or press Ctrl + Shift + G). Your new file is listed under Changes.
- Click the + next to the file to stage it.
- Type a short message in the box, for example Add homepage.
- Click Commit.

Path B (terminal):
git status
git add .
git commit -m "Add homepage"
git status shows the new file in red. git add . stages everything. git commit -m saves the snapshot with your message.
7.3 Push to GitHub and sign in
Path A (VS Code): click Sync Changes in Source Control. Path B (terminal): run this command:
git push origin main
Both paths now do the same thing. This is the first push, so GitHub asks you to sign in:
- A sign-in prompt appears. Choose Allow or Sign in with your browser.
- Your browser opens GitHub. Log in and click Authorize.
- Return to VS Code or the terminal. The push finishes by itself.

Your sign-in is saved by Git Credential Manager, so later pushes will not ask again on this computer.
IF YOU ARE ASKED FOR A PASSWORD GitHub does not accept your account password for Git. Create a personal access token instead: GitHub Settings, then Developer settings, then Personal access tokens. Give it permission to read and write repository contents, copy it right away, and paste it where Git asks for a password.
7.4 Confirm it worked
- Open your repository page on GitHub and refresh it.
- You should see index.html and the message Add homepage.
See your history, Path A: click Git Graph in the VS Code status bar (bottom). It needs the extension from Step 4. Each dot is a commit.
See your history, Path B: no extension needed. Run:
git log --oneline --graph --all
YOU SHOULD SEE index.html on GitHub, and your commit "Add homepage" at the top of the history. Setup complete.
Common Problems and Fixes
| Problem | Fix |
| git is not recognized | Close the terminal and open a new one. If it still fails, restart your PC or reinstall Git. |
| Author identity unknown | Run both commands from Step 3 (user.name and user.email). |
| Authentication failed | Sign in again when prompted, or use a personal access token (see the orange box in Step 7). |
| not a git repository | You are in the wrong folder. Open the cloned project folder in VS Code and try again. |
| rejected / non-fast-forward | GitHub has newer changes. Run git pull, then push again. |
Git Commands Cheat Sheet

How do I set up Git in VS Code? +
Install Git from git-scm.com, set your name and email with `git config --global`, then open your project in VS Code. VS Code finds Git automatically. Run `git --version` in the terminal (Ctrl + `) to confirm.
How do I config a Git username and email? +
Run git config --global user.name "Your Name" and git config --global user.email "you@example.com" in any terminal.
How do I check my git config? +
Run git config --list to see every setting, or git config user.name and git config user.email for one value.
What does git config --global do? +
It saves the setting in the .gitconfig file in your home folder, so it applies to every repository for your user account.
Is the Git username the same as my GitHub username? +
No. The Git user.name is a label on your commits. Your GitHub username is your login. They can be the same, but they are separate settings.
How do I connect VS Code to GitHub? +
Clone a repository with Git: Clone, make a commit, and click Sync Changes. Approve the GitHub sign-in prompt that appears on your first push.
Do I need to install Git before VS Code? +
Either order works, but VS Code needs Git on your computer to use Source Control. If you installed Git second, restart VS Code.
Why does Git keep asking for my password? +
Your sign-in is not being saved. Make sure Git Credential Manager was kept enabled during installation, or use a personal access token.
Be the first to comment.