Friday, August 21, 2015

Lesson 55: git rm -cached, git assume unchanged, and git reset

Important:
It is recommeded to use git rm -r --cached <file/directory>
You dont want to track specific gradle / android studio file, because others will always generate different according to their development environment.
for all files mentioned in .gitignore you can use this command:

git rm -r --cached .
 source:
http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository

------
http://stackoverflow.com/questions/9750606/git-still-shows-files-as-modified-after-adding-to-gitignore

effect: files stay on local, but deleted on repo
example command:
git rm -r --cached .idea/
git rm -r --cached *.class

http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository

vs

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

effect: files not comming, removed from (Git) index
example command:
git update-index --assume-unchanged <file>

UPDATE: to view list of assume unchanged files use this command:
git ls-files -v | grep ^[a-z]

--------------------------------------------------------------

UPDATE 2: git rm vs git reset
Well, no, a git rm has not the same behavior as a [git reset][8].
Both will affect the index, but:

  • one (the git rm) will record a file for deletion on the next commit, hence the 'deleted' status,
  • the other (git reset) will copy HEAD to the index, resetting said index back to what the file was in HEAD.

http://stackoverflow.com/questions/15455686/git-rm-cached-and-deleted-status

No comments:

Post a Comment