The Testing Academy · Guides VS Code · GitHub Copilot · Git
Guide · 2 videos · watch and follow

Push your code from VS Code to GitHub with GitHub Copilot

You give the command in plain English, and GitHub Copilot's agent does the git work. Part 1 sets everything up and makes your first push. Part 2 is the one prompt you send every day after that. Copilot's free plan is enough.

01

What you need

  • Git installed on your computer, from git-scm.com. Git is what keeps the history of your code; without it nothing can be committed.
  • A GitHub account.
  • VS Code with GitHub Copilot. The free plan is enough for this.
  • A project folder with your code in it.

You do not type a single git command. You write a prompt, Copilot works out the commands, and you approve them. Only two things need real action from you: the token and the empty repository. Everything else is a click or a short answer.

02

Twelve git words

To prompt Copilot well, you need to know what you are asking for. These twelve words are enough.

WordWhat it means
GitA tool on your computer that tracks changes in your code.
GitHubA website that stores your Git projects online, so others can work with you and see your work.
RepositoryA project folder that Git keeps track of.
LocalThe copy on your computer.
RemoteA copy stored somewhere else, like GitHub.
OriginThe nickname for your remote on GitHub.
MainThe default branch: your main line of work.
StagePick which changes go into the next save.
CommitA saved snapshot, with a short message.
PushSend your commits from your computer to GitHub.
PullBring new commits from GitHub to your computer.
TokenA password made for apps like VS Code.

A commit works like the undo history of a document: you get back whole versions, not single letters. Each commit is stored with a message, a time and an ID.

STAGE, COMMIT, PUSH YOUR COMPUTER Working folder your files YOUR COMPUTER Staging area changes picked for the next YOUR COMPUTER Local repo commits, each with an ID GITHUB origin / main the copy online git add git commit git push git pull
Your changes are staged, then committed on your own computer. Only a push puts them on GitHub, and a pull brings other people's commits back.
The prompt formula: action + place + message. For example: "Commit my changes with the message 'add login test' and push to origin main."
03

Part 1: the first push

The video above walks through this part. You do it once per project.

PART 1: THE FIRST PUSH GITHUB Create a token classic, with the repo scope GITHUB Create an empty repo no README, copy the URL VS CODE Open your folder Copilot Chat in Agent mode COPILOT CHAT Send Prompt 1 your repo URL and token COPILOT AGENT Runs the git commands init, add, commit, push after you click Allow GITHUB Refresh your repo your files and first commit then, in VS Code
The first push: two steps on GitHub, one in VS Code, and one prompt. Copilot runs the commands; you approve them.

1. Create a token on GitHub

  1. Go to Settings › Developer settings › Personal access tokens › Tokens (classic), then Generate new token.
  2. Give it a name, tick repo, and generate it.
  3. Copy the token and keep it somewhere safe for the next few minutes. GitHub shows it only once.

2. Create an empty repository

  1. On GitHub, click + › New repository and give it a name.
  2. Choose Public if you want others, interviewers included, to see it.
  3. Leave the README off, so the repository stays empty, and create it.
  4. Copy the HTTPS URL of the repository.

The repository name and your folder name do not have to match, because Git links them by the URL. Keeping them the same just helps you remember.

3. Open your folder in VS Code

File › Open Folder, then open Copilot Chat and switch the mode to Agent. In Ask mode, Copilot only talks; Agent mode is what lets it run commands.

4. Send Prompt 1

Copy it, replace the capital words with your repository URL and your token, and paste it in Copilot Chat:

Prompt 1: first time only
This is my GitHub repository URL: https://github.com/YOUR-NAME/YOUR-REPO.git
and this is my token: PASTE_YOUR_TOKEN_HERE.
Check that git is installed, set up this folder as a git repository, create a .gitignore, update the README.md file with a short description of this project,
commit all files with proper message and push the code to that URL on the main branch.
Use the token only for this push. Do not save it in any file or in the git config.

The two lines that matter most are the URL and token, and "commit all files with proper message and push the code to that URL on the main branch". The rest is optional, and your own words work too.

A token typed in chat is like a password. Use a token that expires soon, and delete the chat after your first push.

5. Click Allow

Copilot decides which git commands to run and asks before each one. Click Allow or Continue every time. The first push takes a little longer, because the repository is being set up.

6. Check GitHub

Refresh your repository page. Your files are there, with the first commit and its message.

04

Part 2: push every day after that

After the first push, the token and the link to GitHub are already set up. From then on, at the end of every class or piece of work, it is one prompt:

Prompt 2: every day after that
Update the main README.md file, commit all changes with a clear message and push the code.
PART 2: EVERY DAY AFTER THAT VS CODE Write code new and changed files COPILOT CHAT Send Prompt 2 update, commit, push COPILOT AGENT Does the git work you click Keep, then Allow GITHUB New commit online with a clear message next day, the same prompt
The daily loop: write code, send Prompt 2, approve, and the new commit is on GitHub. No token, no setup.
  • Keep, then Allow. When Copilot edits a file, such as the README, it asks you to Keep the change. When it wants to run git, it asks you to Allow.
  • An edit is not a push. Until the change is committed and pushed, GitHub does not have it.
  • No message needed. If you do not give a commit message, Copilot writes a clear one for you.
  • The README missed a file? Ask: "Update the repo structure in README.md with all the files."

The wording does not have to match. Anything that says update, commit and push will do.

05

When Copilot stops and asks you

Copilot cannot do these for you:

What you seeWhat to do
Copilot asks to run a commandClick Allow or Continue. It cannot run anything without your approval.
Copilot only talks and runs nothingSwitch the chat from Ask mode to Agent mode. Ask mode cannot run commands.
"git is not recognized", or git is not installedInstall Git from git-scm.com, restart VS Code, then paste the prompt again.
It asks for your name and emailType them. Use the same email as your GitHub account.
A sign-in or password box appearsThe username is your GitHub username. In the password box, paste the token, not your GitHub password.
Authentication failedThe token is wrong, expired, or missing repo. Create a new token and try again.
Push rejectedThe GitHub repository was not empty. Ask Copilot: pull from origin main, then push.
06

Common questions

  • Must the folder name and the GitHub repo name match?No. Git links them with the repository URL. The same name just helps you remember.
  • Must my Git name match my GitHub username?No. For your commits to show on your GitHub profile, use an email that is added to your GitHub account.
  • Public or private repository?Public is fine for practice, and lets you show your work on your resume. Choose private for anything you want to keep to yourself.
  • I see "master", but GitHub says "main".Ask Copilot: rename my branch to main and push it to origin.
  • Do I push every time I save a file?No. Commit when a piece of work is done, then push to back it up. At the end of each class is a good habit.
  • I pasted my token in my code.Delete that token on GitHub right away, and create a new one.
You give the command. Copilot does the git work. Knowing the words is the real skill.
07

Reference links