Git itself knows nothing about Composer, or even PHP. What gets rolled back when you checkout a commit, reset, etc, depends entirely on what files you commit.
In Composer, there are three places where a package ends up:
- Listed in
composer.json
. This is the file you edit by hand. It tells Composer what packages you depend on, and what the minimum and maximum versions it's allowed to use, but not the specific version installed.
- Listed in
composer.lock
. This is the file that Composer generates when you run composer update
(and some other commands). It lists exact versions of every package installed, including indirect dependencies (packages needed by other packages, rather than listed directly in your composer.json
).
- Actually installed in the
vendor
directory. These are the files PHP will actually execute.
As the Composer documentation explains for a standalone project, you should normally commit both composer.json and composer.lock, but not vendor
. This allows you to install the exact same versions each time you switch branch, deploy to a new server, etc, by running composer install
.
If this is what you've done, then by resetting to or checking out the commit before you updated the package, you will get your old composer.lock
, but git won't touch your vendor
directory.
To actually install the packages listed in that composer.lock
, you would run composer install
. That will make the content of your vendor
directory match the exact versions listed in composer.lock
, including uninstalling things which aren't listed there.