![]() ![]() ![]() All file changes must be staged before they can be committed, and git add is the tool we use to add file. ![]() Staging is used to track new files in Git and update existing files. In other words, after this operation, changes happen in your working directory, NOT your staging directory. The staging area is a temporary holding location for adding changes before actually committing them to the repository, and eventually pushing them to a central repository. This command is for the situation when the file has been staged, but the file has been modified in working directory after it was staged, use this operation to restore the file in working directory from staging directory. PS: I have noticed some answers mentioned: If you don't want to keep that record and just simply want to undo a previous stage operation of a file, use git reset HEAD instead. It's a record of removing the file from staging directory. But notice that this operation will not only remove the file from staging directory but also mark the file as deleted in staging directory, if you use git statusĪfter this operation, you will see this : deleted: You simply want to "undo" the git add that was done for that file.Ĭommonly, there are two ways to undo a stage operation, as other answers already mentioned: git reset HEAD Īssume the file has been staged and exists in working directory too, use git rm -cached if you want to remove it from staging directory, and keep the file in working directory. You can simply consider staging directory and index as the same thing. I think you probably got confused with the concept of index, as Bailey commented: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |