user10201522
user10201522

Reputation:

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: enter image description here

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 ..

Upvotes: 0

Views: 36

Answers (3)

L483
L483

Reputation: 226

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.

Upvotes: 1

ashunt
ashunt

Reputation: 64

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.

Upvotes: 1

Shrey Garg
Shrey Garg

Reputation: 1337

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

Upvotes: 1

Related Questions