Reputation: 501
I keep seeing deleted files every time I switch branches. I already committed all the changes I had done.
git checkout master
D eqs.jpg
D old conversion.pdf
D readme.txt
What should I do to avoid it?
Upvotes: 5
Views: 3527
Reputation: 19035
This means that you have deleted the three files locally, but have not committed that deletion. If you want the files deleted from the repository as well, you need to git add --all
and git commit
. If you do not want them deleted, do a git checkout .
to restore them locally.
Upvotes: 4
Reputation: 142164
You have to clean your working folder or to commit the changes.
# (x/X) are different case
git clean -Xfd
git clean -xfd
-x
Don’t use the standard ignore rules read from .gitignore (per directory) and $GIT_DIR/info/exclude, but do still use the ignore rules given with
-e
options.This allows removing all untracked files, including build products.
This can be used (possibly in conjunction withgit reset
) to create a pristine working directory to test a clean build.-X
Remove only files ignored by Git.
This may be useful to rebuild everything from scratch, but keep manually created files.
# remove the file from cache git clean --cached
git add -A
# or:
git rm --cached <file>
Upvotes: -2