Step-by-step guide
🤖 GitHub Copilot
GitHub
📘 Step-by-step guide 📘 GitHub · GitHub Copilotbeginner 🔄 Life & Business

How to Automate Git Commands with GitHub Copilot Suggestions

Learn how to use GitHub Copilot to suggest and run everyday Git commands, saving you from memorising complex terminal codes.

Hook: If you have ever felt overwhelmed by the cryptic commands needed to save and organise your programming work, you are not alone. This guide will show you how to let GitHub Copilot do the heavy lifting, turning natural language into ready-to-use Git commands directly inside your workspace.

Before we dive in, let us clarify a couple of terms. Git is a version control system—think of it as a digital time machine for your project files, keeping track of every change so you can undo mistakes. The terminal (or command line) is a text-only window where you type direct instructions to your computer instead of clicking buttons.


✅ Before you start
  • Make sure you have Visual Studio Code (a popular, free code editor) installed.
  • Ensure you have an active GitHub Copilot subscription.
  • Install the GitHub Copilot and GitHub Copilot Chat extensions inside your editor.

1

Open your terminal chat

To begin, we need to open the terminal inside your code editor and access Copilot. This allows you to ask for help exactly where you write your commands.

  1. Open your project folder in your code editor.
  2. Open the built-in terminal by pressing Ctrl + \`` (backtick) on Windows or Cmd + `` on a Mac.
  3. Look for the Copilot icon in your terminal panel, or press Ctrl + I (or Cmd + I) while your cursor is in the terminal to open the inline helper.
💬 Try typing thisOnce the prompt box appears, you are ready to ask for instructions using everyday language.

2

Ask for a basic save command (Git Commit)

In Git, a commit is like saving a checkpoint in a video game. Instead of trying to remember the exact syntax to stage and save your files, you can just ask Copilot.

  1. In the terminal chat box, type a simple request.
  2. Copilot will generate the exact text command for you.
  3. Click the button next to the suggestion to insert it directly into your terminal, or press enter to run it.
💬 Try typing thisType: *"How do I stage all changes and commit them with the message 'fixed the contact page contact form'?"*

Copilot will suggest:

git add . && git commit -m "fixed the contact page contact form"

3

Create a new sandbox (Git Branch)

A branch is a parallel universe of your project. It lets you safely test new ideas or build new features without messing up the main, working version of your website or application.

  1. Open your terminal chat again.
  2. Ask Copilot to create a new branch and switch you into it.
  3. Review the suggested command and run it.
💬 Try typing thisType: *"Create and switch to a new branch called design-update"*

Copilot will suggest:

git checkout -b design-update

4

Safely combine your work (Git Merge)

Once you are happy with your changes in your sandbox branch, you need to bring them back into your main project. This process is called merging. Copilot makes this safe by reminding you of the correct order of steps.

  1. Tell Copilot what you want to achieve in plain English.
  2. Copilot will give you a sequence of commands to ensure you do not accidentally overwrite your work.
💬 Try typing thisType: *"How do I merge my current branch back into the main branch?"*

Copilot will suggest a clear sequence:

git checkout main
git merge design-update

⚠️ Common mistakes
  • Blindly running commands: Always read the command Copilot suggests before pressing Enter. AI is incredibly helpful, but it does not know your project's history as well as you do.
  • Forgetting your location: Before running a command to save or merge, make sure you are in the correct folder. If you are unsure, ask Copilot: "How do I check which folder I am currently in?"

🚀 Try it now

Let us do a quick test. Open your editor terminal, trigger the Copilot chat, and type: "How do I check the status of my current files?"

Watch how quickly it suggests git status—the foundational command to see what has changed in your project.

✦ Original step-by-step guide by AI World Co.'s AI editorial team. Written in plain language, reviewed for accuracy.

← Back to all stories