# How to commit changes in VS Code on Mac: step by step for 2026

> How to commit changes in VS Code on Mac: open Source Control with ⌃⇧G, stage your files, type a message, and click Commit. Includes Git setup and fixes.

URL: https://www.lazur.app/how-to/commit-changes-in-vs-code
Updated: 2026-11-09

To commit changes in VS Code on Mac, open Source Control with ⌃⇧G, click the + next to each file you want to save, type a message in the box at the top, and click Commit. If Git does not know your name yet, set it once in Terminal before your first commit.

## Quick answer

- Press ⌃⇧G to open Source Control. Hover over a file and click the + icon to stage it.
- Type a short message in the commit message box at the top, then click Commit.
- Set your Git name and email once with git config before your first commit.
- Undo Last Commit only works on commits you have not pushed yet.

Applies to: VS Code 1.14x on macOS, Apple silicon and Intel Macs. Time: 5 min. Difficulty: Easy.

## What you need

- VS Code installed on your Mac, Apple silicon or Intel
- A project folder that is already a Git repository
- Git installed and working in Terminal
- Your name and email address for Git commit labels

## How to Commit changes in VS Code on Mac in VS Code on a Mac

1. **Confirm your Git name and email.** Git needs an author name and email before your first commit. Open Terminal and run the git config commands from the section above. Without them, the commit fails with a message about user.name and user.email. You only do this once per Mac. Tip: Run git config --global --list to see which values Git will use.
2. **Open the Source Control view.** (View > Source Control) Shortcut: ⌃⇧G. Press ⌃⇧G to open Source Control. Your changed files appear in the Changes list. If the list is empty, check that the right folder is open and that it is a Git repository. Tip: Menu names can change between releases. Trust the shortcut if your menu looks different.
3. **Review the diff.** Click a file in Changes to open its diff. Added and removed lines show side by side. Look for debug output, stray test values, and edits you did not plan. Fix those now, before you stage anything. Tip: Check every file you plan to commit, not only the one you changed last.
4. **Stage the files for this commit.** Hover over a file in Changes and click the + icon. You can also right-click the file and choose Stage Changes. Each staged file moves to the Staged Changes list. Files you leave behind stay out of this commit. Tip: Stage the smallest set of files that makes one logical change.
5. **Check the Staged Changes list.** Look at Staged Changes one more time. It should list only the files that belong in this commit. If a file is wrong, move it back out, then stage the right one. This list is what Git saves. Tip: A file in the wrong list is the most common reason a commit surprises people.
6. **Type a commit message.** Click the commit message input box at the top of Source Control and type a short subject line. Write it in the present tense, such as Fix login redirect. Add a longer body only if the reason is not clear from the subject. Tip: Aim for a subject line you can read in a list of commits without opening each one.
7. **Click Commit.** Click Commit. The staged files leave Staged Changes, and Git saves the commit to your repository. If the message box is empty, VS Code opens COMMIT_EDITMSG so you can write one. Select Cancel to stop. Tip: Use the dropdown next to Commit only when you want to amend the last commit.
8. **Check the result and decide about pushing.** Confirm that Staged Changes is empty. Any file you left unstaged still shows in Changes, which is expected. Push when you want to share the commit with your remote. Pushing is a separate step, and nothing leaves your Mac until you do it.

A commit is a saved snapshot of your project, with a message that says what changed. Git keeps every commit in your repository's history, so you can look back, compare, or undo later. VS Code does not replace Git. It shows Git's work in a panel, so you can stage, commit, and undo without leaving the editor. The steps here match the 1.14x line of VS Code, which is current as of November 2026.

- **1.145** Latest stable VS Code release, November 4, 2026. The steps here match the 1.14x line. ([source](https://code.visualstudio.com/updates))
- **75.9%** Of all respondents in the 2025 Stack Overflow survey use Visual Studio Code. ([source](https://survey.stackoverflow.co/2025/technology))

## What you need before you commit in VS Code

You need VS Code on your Mac. The official setup page lists builds for Apple silicon, for Intel chips, and a Universal build that works on both. The latest stable release is 1.145, released November 4, 2026, with patches 1.145.1 and 1.145.2. Install the newest build so your menus match this guide.

You also need Git, and your project folder must already be a Git repository. Stack Overflow's 2025 developer survey found that 75.9% of respondents use Visual Studio Code, so this workflow is common. Most of what you learn here carries over to other editors that use Git.

- Run git --version in Terminal. A version number means Git is installed and available to VS Code.
- Open your project with File > Open Folder. A folder with a hidden .git folder inside is a repository.

If the folder is not a repository yet, run git init inside it from Terminal. Git then starts tracking changes in that folder, and Source Control has something to show you.

## Open the Source Control view on Mac

Source Control is the panel where VS Code shows Git work. Press ⌃⇧G to open it. That is Control, Shift, and G pressed together. You can also open it from the menu bar at View > Source Control. Menu names can shift between releases, so the shortcut is the safer bet.

The panel has two lists you need. Changes shows files Git sees as modified. Staged Changes shows the files that will go into your next commit. Only the files in Staged Changes get saved, so pay close attention to that list.

![Developer at a Mac reviewing code changes before they commit them in VS Code](https://images.lazur.app/content-images/howto/commit-changes-in-vs-code/how-to-commit-changes-in-vs-code-1-9312bb.jpg)

## Stage the files you want to save

Staging is how you choose what goes into a commit. Hover over a file in Changes and click the + icon. You can also right-click the file and choose Stage Changes. Staged files move to the Staged Changes list. Unstaged files stay in your folder, and they stay out of the commit.

Here is a common case. You fixed a typo in the README and rewrote a login function in the same session. Stage the README alone and commit it with a message like Fix typo in setup steps. Then stage the login file and commit that separately. Small commits are easier to review and easier to undo than one large commit.

## Review the diff before you commit

Click a file in Changes to open its diff. The diff shows the lines Git added and removed, side by side. Read it the way a reviewer would. Look for debug output, leftover test values, and edits in files you did not mean to touch. Catching these now is much cheaper than a revert later.

## Write a commit message people can read

Type your message in the commit message input box at the top of the Source Control view. Keep the first line short and in the present tense. Say what changed, and add why if the reason is not obvious from the code. You will read these messages again when something breaks.

| Weak message | Better message | Why it helps |
| --- | --- | --- |
| fix | Fix broken link in setup guide | Says what changed and where |
| stuff | Add error handling to login form | Names the feature you touched |
| update | Update Git identity steps for Mac | Gives a reason to look at it later |

_Compare a vague message with one that tells a reader what changed._

![Person typing a commit message on a laptop while writing code at a desk](https://images.lazur.app/content-images/howto/commit-changes-in-vs-code/how-to-commit-changes-in-vs-code-2-f30f6e.jpg)

## What happens when the message box is empty

If you click Commit with the box empty, VS Code opens a COMMIT_EDITMSG tab. Use it to write a longer message, with a short subject line and a body below it. This behavior depends on the git.useEditorAsCommitInput setting, which must be turned on. To stop without committing, select Cancel.

## Commit (Amend), Commit All, and other Commit options

The Commit button has a dropdown. Commit (Amend) rewrites your last commit. Use it to add a file you forgot or to fix the message on the commit you just made. The other commit choices sit in the More Actions menu, under Commit. They include Commit Staged (Amend), Commit All, and Undo Last Commit.

> **Check before Commit All:** Commit All adds every pending file to the commit, not just the staged ones. Review the Changes list first. If a change has several parts, stage the files you want and use the normal Commit button.

Amend is safe on a commit you made a minute ago and have not shared. Once a commit sits on a shared branch, rewriting it can confuse teammates who already pulled it. In that case, add a new commit instead.

## Undo the last commit before you push

Undo Last Commit sits under More Actions, then Commit. It applies only to commits you have not pushed. Your changes stay staged, so you can fix them and commit again. Nothing in your files is lost, and the commit itself is removed from history.

If the commit already reached the remote, the VS Code docs recommend git revert. Revert adds a new commit that reverses the old one, so the shared history stays intact.

> **Pushed commits:** Undo Last Commit does not change a pushed commit. Use git revert for those, so your teammates keep a clean history.

## Set your Git user.name and user.email once

Git labels every commit with an author name and email. Set both once from Terminal. These are labels, not a sign-in, so setting them does not log you in anywhere.

Run git config --global user.name 'Your Name' and then git config --global user.email 'you@example.com', using your own values. The --global flag applies them to every repository on your Mac. Leave it out to set them for one project only, while you are inside that folder.

Open Terminal from Applications > Utilities, or use the terminal inside VS Code. If you want a refresher on that panel, read the guide on toggling the integrated terminal listed at the end of this page.

## Fix the errors you hit when you commit or push

| Message or problem | What to do |
| --- | --- |
| Make sure you configure your 'user.name' and 'user.email' in git | Set both values with git config in the repository folder, then retry the commit. Use --global to cover every repository. |
| Git not found | Run git --version where the repository is open. If it works in Terminal but not in VS Code, set git.path to the full path of the Git program. |
| Push rejected with non-fast-forward or fetch first | The remote has commits your branch lacks. Fetch, commit or stash local work, pull, resolve conflicts, then push. Do not force push. |
| Repeated password prompts | Background fetches from git.autofetch can cause them. Set up a credential helper, or turn off git.autofetch in Settings. |

_Common Git errors in VS Code and the fix for each._

Most errors come from identity, the Git path, or a remote that moved on. Read the message word by word before you change anything. The message usually names the exact setting or branch that needs attention.

## Keyboard shortcuts for committing on Mac

The official docs list the Mac shortcuts below. They do not list a shortcut for Commit itself. Some guides mention ⌘Enter, but the official sources do not confirm it, so do not rely on it. Open the Keyboard Shortcuts editor with ⌘K ⌘S and search for commit to see what your build uses.

| Action | Mac shortcut | Note |
| --- | --- | --- |
| Show Source Control | ⌃⇧G | Opens the panel with Changes and Staged Changes |
| Command Palette | ⇧⌘P | Search any command by name |
| Save file | ⌘S | Save before you stage, so Git sees the final text |
| Keyboard Shortcuts editor | ⌘K ⌘S | Also under File > Preferences > Keyboard Shortcuts |

_Shortcuts from the official VS Code docs for Mac._

## Commit from VS Code for the Web

VS Code for the Web at vscode.dev can commit too. It supports GitHub through the GitHub Repositories extension, and it supports Azure Repos. Uncommitted work sits in browser storage until you commit it. The web version has no terminal and no debugger, so run git config in the desktop app instead.

Some keyboard shortcuts behave differently in a browser. Command-W closes the browser tab, not the editor tab, for example. Commit on your Mac when you need full Git control.

![Mac laptop on a desk with a code editor open for a Git project](https://images.lazur.app/content-images/howto/commit-changes-in-vs-code/how-to-commit-changes-in-vs-code-3-8acade.jpg)

## Mistakes people make when they commit on Mac

- Committing files they did not mean to include. Check Staged Changes one more time before you click Commit.
- Writing messages like fix or stuff. Your history gets hard to search, and nobody can tell what changed.
- Reaching for Commit All out of habit. Stage files on purpose, especially when one change has several parts.
- Forcing a push to get past a rejection. Fetch and pull instead, then push again.
- Skipping the Git identity setup, then wondering why the commit fails. Set it once and you are done.

## How to confirm the commit went through

After you click Commit, the files leave Staged Changes, and the new commit sits at the top of your branch history. If you want the commit on GitHub or Azure Repos, push it to the remote. Pushing is a separate step, so nothing leaves your Mac until you choose to share it.

## Next steps after your first commit

Once committing feels normal, the integrated terminal lets you run Git commands without leaving VS Code. Read the [integrated terminal guide](https://www.lazur.app/how-to/toggle-the-integrated-terminal-in-vs-code) next. For a wider setup, the [developer guide for VS Code on Mac](https://www.lazur.app/for/developers/vs-code) covers Git, shortcuts, and debugging.

If you split your screen to compare a diff with the code, the [split editor guide](https://www.lazur.app/how-to/split-the-editor-in-vs-code) shows the shortcuts for that. Keep the Staged Changes list visible while you work, so the commit only holds what you meant to save.

## Shortcuts

- Show Source Control: ⌃⇧G
- Open Command Palette: ⇧⌘P
- Save file: ⌘S
- Open Keyboard Shortcuts editor: ⌘K ⌘S
- Open Explorer: ⇧⌘E

## If it does not work

- **Make sure you configure your 'user.name' and 'user.email' in git** Set both values with git config in the repository folder, then retry the commit. Use --global to cover every repository on your Mac.
- **Git not found** Run git --version where the repository is open. If it works in Terminal but not in VS Code, set git.path in Settings to the full path of the Git program.
- **Push rejected: non-fast-forward or fetch first** The remote has commits your branch lacks. Fetch, commit or stash local work, pull, resolve any conflicts, then push. Do not force push.
- **Repeated password prompts** Background fetches from git.autofetch can cause them. Set up a credential helper, or turn off git.autofetch in Settings.

## With Lazur

Lazur is a voice assistant for the Mac that lives in the notch. Hold ⌥ ⌘ and ask; it sees your screen, answers out loud, points at buttons and walks you through apps. Hold fn to dictate. Free for 3 days, then $18/month: https://www.lazur.app/download

- “Where is the Commit button in VS Code?”: Lazur draws a circle and a label around the Commit button on your screen. You still click it yourself. (Points at it)

## FAQ

### What is the difference between staging and committing in VS Code?

Staging chooses which changes go into the next commit. Committing saves those staged changes to the repository with a message. A changed file that is not staged stays out of the commit until you stage it.

### Why does VS Code open a COMMIT_EDITMSG tab when I click Commit?

You clicked Commit with an empty message box, so VS Code opens an editor for a longer message. This depends on the git.useEditorAsCommitInput setting. Select Cancel to stop without committing.

### How do I undo a commit in VS Code on Mac?

Open the More Actions menu, go to Commit, and choose Undo Last Commit. It works only if you have not pushed the commit. Your changes stay staged. For a pushed commit, the VS Code docs recommend git revert.

### Do I have to set my Git name and email every time?

No. Set them once with git config --global user.name and git config --global user.email. Git uses those values for every repository on your Mac. They label your commits and do not sign you in anywhere.

### Is there a keyboard shortcut to commit in VS Code on Mac?

The official keyboard shortcut reference does not list one for commit. Some guides suggest ⌘Enter, but official docs do not confirm it. Open the Keyboard Shortcuts editor with ⌘K ⌘S and search for commit to see what your build uses.

### Can I commit from VS Code for the Web in a browser?

Yes, to GitHub through the GitHub Repositories extension, or to Azure Repos. The web version has no terminal and no debugger, so use the desktop app for git config.

### Why does my push fail with non-fast-forward?

The remote has commits your branch does not have. Fetch, pull, resolve any conflicts, then push again. The VS Code troubleshooting page says not to force push.

## Sources

1. [Source Control in VS Code (Overview)](https://code.visualstudio.com/docs/sourcecontrol/overview), Microsoft (VS Code docs), checked 2026-11-09
2. [Staging, Commits & Undo](https://code.visualstudio.com/docs/sourcecontrol/staging-commits), Microsoft (VS Code docs), checked 2026-11-09
3. [Quickstart: use source control in VS Code](https://code.visualstudio.com/docs/sourcecontrol/quickstart), Microsoft (VS Code docs), checked 2026-11-09
4. [Git Troubleshooting in VS Code](https://code.visualstudio.com/docs/sourcecontrol/troubleshooting), Microsoft (VS Code docs), checked 2026-11-09
5. [Setting up VS Code on macOS](https://code.visualstudio.com/docs/setup/mac), Microsoft (VS Code docs), checked 2026-11-09
6. [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/configure/keybindings), Microsoft (VS Code docs), checked 2026-11-09
7. [Default Keyboard Shortcuts](https://code.visualstudio.com/docs/reference/default-keybindings), Microsoft (VS Code docs), checked 2026-11-09
8. [VS Code Updates](https://code.visualstudio.com/updates), Microsoft (VS Code), checked 2026-11-09
9. [VS Code for the Web](https://code.visualstudio.com/docs/editor/vscode-web), Microsoft (VS Code docs), checked 2026-11-09
10. [Stack Overflow Developer Survey 2025: Technology](https://survey.stackoverflow.co/2025/technology), Stack Overflow, checked 2026-11-09
