VS Code Git and Source Control Cheat Sheet
Sidebar
Programming · VS Code Git and Source Control Cheat Sheet
The git.* and scm.* settings and the everyday source control actions in VS Code. Exact ID, what it does, and its default. Sheet 8 in the VS Code series. This covers VS Code's own settings, not Git commands (see the Git & GitHub courses for those).
Everyday Source Control
Ctrl+Shift+GOpen the Source Control viewCtrl+EnterCommit, when the cursor is in the commit message box+ / − on a fileStage / unstage that file; the + on the Changes heading stages everythingGit: Initialize RepositoryCommand Palette: turn the open folder into a Git repositoryGit: CloneCommand Palette: copy a remote repository to your machineGit: Create Branch / Git: Checkout to…Make a new branch / switch branch (also: click the branch name in the status bar)Git: Pull / Push / Fetch / SyncCommands for talking to the remote; Sync pulls then pushesGit: StashPut uncommitted changes aside (Git: Pop Stash brings them back)Fetching, Pulling & Syncing
git.autofetchfalse (default), true, all: fetch from the remote in the backgroundgit.autofetchPeriodSeconds between background fetches (default 180)git.autorefreshRefresh the Source Control view when files change (default true)git.confirmSyncAsk before syncing (default true)git.fetchOnPullFetch everything when you pull (default false)git.pruneOnFetchRemove remote branches that no longer exist (default false)git.rebaseWhenSyncRebase instead of merge when you sync (default false)git.autoStashStash and restore changes automatically around a pull (default false)git.postCommitCommandAfter committing: none (default), push, syncCommitting
git.enableSmartCommitCommit all changes when nothing is staged (default false)git.smartCommitChangesall (default) or tracked: which changes a smart commit includesgit.suggestSmartCommitOffer smart commit when nothing is staged (default true)git.promptToSaveFilesBeforeCommitalways (default), staged, never: save unsaved files firstgit.inputValidationWarn when the commit message is too long (default false)git.inputValidationSubjectLengthFirst-line length that triggers the warning (default 50)git.inputValidationLengthOverall line length that triggers the warning (default 72)git.verboseCommitShow the diff in the commit message editor (default false)git.enableCommitSigningSign commits with GPG or SSH (default false)git.requireGitUserConfigInsist that user.name and user.email are set (default true)Branches & Cloning
git.defaultBranchNameName for the first branch of a new repository (default main)git.branchPrefixText added in front of new branch names, e.g. feature/ (default empty)git.branchSortOrdercommitterdate (default) or alphabeticallygit.branchValidationRegexPattern that new branch names must match (default none)git.checkoutTypeWhat the checkout list shows (default local, remote, tags)git.openAfterCloneprompt (default), always, alwaysNewWindow, whenNoFolderOpengit.defaultCloneDirectoryFolder cloned repositories go into (default none)git.showReferenceDetailsShow last commit details in the branch picker (default true)Pushing
git.allowForcePushEnable force-push commands (default false)git.useForcePushWithLeasetrue (default): force-push only if nobody else has pushed since you last fetchedgit.confirmForcePushAsk before force-pushing (default true)git.showPushSuccessNotificationShow a message after a successful push (default false)What the Git Extension Shows
git.untrackedChangesmixed (default), separate, hidden: where new untracked files appeargit.openDiffOnClickClicking a changed file opens its diff (default true)git.decorations.enabledColours and badges on files in the Explorer (default true)git.showInlineOpenFileActionOpen File button on each change (default true)git.detectSubmodulesDetect submodules (default true)git.repositoryScanMaxDepthHow deep VS Code looks for repositories in subfolders (default 1)git.ignoredRepositories / git.scanRepositoriesRepositories to ignore / extra folders to scan (default none)git.ignoreLimitWarningSilence the warning about too many changes (default false)git.enabled / git.pathTurn the extension off, or point it at a specific git program (defaults: on, auto-detected)Source Control View (scm.*)
scm.defaultViewModelist (default) or treescm.defaultViewSortKeypath (default), name, statusscm.compactFoldersCompact single-child folder chains in tree mode (default true)scm.autoRevealSelect the active file in the view (default true)scm.countBadgeBadge on the activity bar: all (default), focused, offscm.diffDecorationsChange marks in the editor: all (default), gutter, overview, minimap, nonescm.alwaysShowActionsAlways show inline action buttons (default false)scm.alwaysShowRepositoriesAlways list the repositories pane (default false)scm.graph.pageSizeCommits loaded at a time in the graph (default 50)Timeline, Blame & Diffs
git.timeline.showAuthorShow the author in the Timeline view (default true)git.timeline.datecommitted (default) or authoredgit.blame.editorDecoration.enabledShow who last changed each line, inline (default false)git.blame.statusBarItem.enabledBlame for the current line in the status bar (default true)diffEditor.renderSideBySidetrue: side-by-side diff; false: inlinediffEditor.ignoreTrimWhitespaceIgnore whitespace-only changes at line ends in diffsMerge Conflicts
Accept Current / Incoming / BothThe links shown above each conflict block in the editorCompare ChangesLink above a conflict: opens the two versions side by sidegit.mergeEditortrue: open conflicts in the three-way merge editor (default false in this version)mergeEditor.diffAlgorithmadvanced (default) or legacy (plus external/wasm variants)Resolve in Merge EditorButton on a conflicted file, available when git.mergeEditor is onA Reasonable Starter Set (my suggestions, not defaults)
"git.autofetch": trueAlways know whether the remote moved"git.confirmSync": falseSkip the sync prompt once you trust the habit"git.pruneOnFetch": trueDrop remote branches that were deleted"git.inputValidation": trueNudges you towards short subject lines"git.blame.editorDecoration.enabled": trueInline blame for who changed what"git.mergeEditor": trueA clearer way to resolve conflicts"git.enableSmartCommit": falseKeep commits deliberate (this is the default)Why did Sync prompt me, and what did it do?
Sync Changes runs a pull and then a push. With git.confirmSync on (the default) VS Code asks first, because a pull can change your files. If you prefer to rebase rather than merge when pulling, turn on git.rebaseWhenSync. If you would rather see what is coming before pulling, use Git: Fetch or turn on git.autofetch and check the Source Control view.
Force push, carefully
Force-pushing is off by default (git.allowForcePush). If you turn it on, keep git.useForcePushWithLease on: the push then fails if someone else has pushed new commits since your last fetch, instead of overwriting their work.