Reputation: 4463
I have cloned a git repo. During building, a lot of files in certain folder is showing to be deleted while doing: git status.
They are already in remote repo which I don't want to delete. Regarding this, I have gone through following post: Git ignore deleted files
After that I put the directory in .gitignore as well. Still while doing git status, I can see the same.
Upvotes: 1
Views: 1785
Reputation: 34947
remote
This will not work long term. When someone else clones your repo they will get the files.
>git checkout .
will restore the deleted files.
/mnt/c/git/repo666 (branchX)>git status
On branch branchX
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: a.txt
no changes added to commit (use "git add" and/or "git commit -a")
/mnt/c/git/repo666 (branchX)>git checkout .
/mnt/c/git/repo666 (branchX)>git status
On branch branchX
nothing to commit, working tree clean
/mnt/c/git/repo666 (branchX)>
Upvotes: 1
Reputation: 12959
If you are still seeing them in the git status, it could be due to cache.
Remove all files from cache, using the below command
git rm -r --cached .
If you want the ignoring to happen across repositories -> update gitignore
Post update, add files individually as per your commit
git add .
If you want the ignoring to happen only local repository and not at the repository level, update the exclude file: $GIT_DIR/info/exclude, instead of git ignore
Post update, add files individually as per your commit
git add .
Read more on ignoring files in GIT
Upvotes: 1