user5858 user5858 - 2 months ago 9
Git Question

git reset HEAD file touches many other files too

I've been using git for a couple of years and after adding a file using "git add" we can unstage it using command "

git reset HEAD file1 file2
".

This command is even specified when we try to commit changes:


(use "git reset HEAD ..." to unstage)


To my understanding it only unstages the specified files and do nothing else.

Today I gave this command

git reset HEAD a.php test.php #to unstage some left over test files


after running it it generated lot of warnings like

M public/www.mysite.com/public/sites/all/modules/unique_field/unique_field.module
M public/www.mysite.com/public/sites/all/modules/variable/variable.module
M public/www.mysite.com/public/sites/all/modules/variable/variable_admin/variable_admin.module
M public/www.mysite.com/public/sites/all/modules/variable/variable_example/variable_example.module
M public/www.mysite.com/public/sites/all/modules/variable/variable_realm/variable_realm.module
M public/www.mysite.com/public/sites/all/modules/variable/variable_store/variable_store.module
M public/www.mysite.com/public/sites/all/modules/variable/variable_views/variable_views.module
M public/www.mysite.com/public/sites/all/modules/views/tests/views_test.module
M public/www.mysite.com/public/sites/all/modules/views/views.module


This answer confirms what I understand Does `git reset HEAD file` also check out the file? but why it always show lot of warnings which seem to be that those
"M"
files have been modified.

Can anyone explain me this threatening what "
M
" means and why it should be even listing such warnings?

Answer

M means that the working version of the file and the version you have in your last commit are different. You can check where differences are using git diff <namefile> The command you ran only unstage files. The most probable explanation is that you had all those modified files also before running your git reset command. Maybe those files are generated/created by the application you are working on...

Comments