Differences between Commit, Commit Staged, and Commit All in VS Code

Viewed 1324

There are three commands for Git committing in Visual Studio Code:

  • Commit
  • Commit Staged
  • Commit All

What are the differences between them?

Unfortunately, I have not found any documentation or web pages on this. (I am not interested in the differences between git pull and git fetch or commit – amend or commit – signed off as most searches suggest – all of these are documented well. The Commit command is also missing in the comprehensive list in the German article Visual Studio Code (7): Git als Quellcodeverwaltung einsetzen, for example.)

2 Answers

I tried to run "Commit" from my instance of VS Code, and it prompted me with a message :

There are no staged changes to commit.
Would you like to stage all your changes and commit them directly ?

[Never] [Cancel] [Always] [Yes]

So my guess is : it's just a command which checks your local configuration or interactively asks you what to do.
In the end, it applies either "Commit staged" or "Commit all".

I observed the VS Code behaviour by the git log window and I discovered that both commit and commit all option, it logs a git add -A -- . so the result is the same.

> git add -A -- .
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
> git status -z -u
> git symbolic-ref --short HEAD
> git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master
> git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname)
> git remote --verbose
> git config --get commit.template
> git ls-tree -l HEAD -- /home/antonio/tmp/vscode/f9
> git show --textconv HEAD:f9
> git status -z -u
> git symbolic-ref --short HEAD
> git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master
> git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname)
> git remote --verbose
> git config --get commit.template

In my opinion it maybe a bug!

Related