X
X
Xeli2017-08-17 17:42:09
linux
Xeli, 2017-08-17 17:42:09

Is there a difference between the rm --cached and reset HEAD commands?

Hello. Who can tell what is the difference between the commands $git rm --cached <file>and $git reset HEAD <file>? I checked it now, they seem to act the same way - they delete the specified files from the index. What's the Difference?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
Xeli, 2017-08-17
@Xeli

The command $git rm --cached <file>removes the file from being tracked (the status of the file is untracked), the command $git reset HEAD <file>removes the file from the index , but leaves the file in tracked , i.e. it is used to remove the file from being included in the commit in case of an error git add .but leave it under git version control. This is the difference.

V
Victor, 2017-08-17
@v_decadence

The first removes the file from the index but leaves it on disk. Usually done for ignored files that accidentally got into the index.
The second brings the index state of the file to the one that was after the last commit (in fact, it will reset the indexed changes).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question