문제

When I run git status:

$ git status
# On branch master
# 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)
#
#       modified:   .gitignore
#       modified:   .project
#       modified:   reports/images/2014-03.png
#       modified:   reports/images/graph-2014-03.bmp
#       deleted:    reports/phpbmp/cache/0/02/027/0270/phpThumb_cache_portal.gep.co.za_src02707010e1e50bc80594
f31460d514c4_par80d8993b181666aca11d7be02b12fea7_dat1399293161.bmp
#       deleted:    reports/phpbmp/cache/0/02/027/0270/phpThumb_cache_portal.gep.co.za_src02707010e1e50bc80594
f31460d514c4_par80d8993b181666aca11d7be02b12fea7_dat1399293182.bmp
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       README.MD
#       reports/phpbmp/cache/9/
no changes added to commit (use "git add" and/or "git commit -a")

I realised that I don't want changes to the following files be tracked:

.project
reports/images/*.png
reports/images/*.bmp
reports/phpbmp/cache/*

So I added these files to .gitignore

How do I remove the files from the current working directory under Changes not staged for commit?

도움이 되었습니까?

해결책

If I understand well you want filename to be in the git repository. However you don't want to be notified of new changes to filename. You can do this using this command:

git update-index --assume-unchanged <filename>

If you wanna start tracking changes again run the following command:

git update-index --no-assume-unchanged <filename>

additional info: editing .gitignore will only ignore files so they will not be added to the git repository. However files that are tracked already will not be ignored.

다른 팁

Files are already tracked and now you want to ignore those files.

git rm --cached filename 
echo "filename" >> .gitignore
git add .gitignore
git commit -m 'Removes filename file and adds it to gitignore.'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top