简体   繁体   中英

Delete a file from my local changes (GIT)

I made some changes in my project. When i type git log i got the next changes: 在此处输入图像描述

The question is: How to delete from this list of changes the file demo.js ? What command should i use? I want to do this, because i don't want to add all files in my remote repository using the command git add. .

Use this command

git checkout -- <file-path>

<file-path> can be replaced by . if all files are to be removed


To remove all changes from demo.js :

git checkout -- demo.js

If you want git not to track those files, add them to .gitignore :

echo demo.js >> .gitignore
echo test.html >> .gitignore

You can place multiple .gitignore files anywhere in the repo.

Since it is an untracked file, you can delete it with your regular "file deletion command" of your shell. In case you want to still keep the file locally on your computer, you are better of by putting it into your .gitignore file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM