Cant discard file changes in GIT -
Cant discard file changes in GIT -
i faced problem, can't discard changes file. in diff showed lines deleted , new pasted. content of file similar initial commit in branch. intellij thought shows there no diff repository.
i new 1 git, please patient)
my best guess happening on windows machine, , somewhere in .gitattributes
file have directive tells git perform line ending normalizations (via * text=auto
or similar). if indeed case, when checkout file lfs converted crlfs, , when commit file crlfs converted lfs.
if indeed case, happening repository version of files in question somehow have crlfs in them. when check them out, working copies of course of study have crlfs. here's rub: when doing git status
, git diff
, etc. git compares in repo/index not in working directory, would committed after line ending normalization done, i.e. crlfs replaced lfs. in case, git sees in index/repo has crlfs, , would commit has lfs, , there difference.
to see if case, run next commands:
git hash-object path/to/filename git hash-object --no-filter path/to/filename git ls-files -s path/to/filename
the first command show hash of would committed. sec command shows hash of in working directory. 3rd command shows hash of in index. if first , sec hashes different, , sec , 3rd hashes same, in situation have described.
so question is, how out of it? 1 simple way add/commit "changes". have effect of putting lfs in repository copy, solving problem going forward. if using repository on windows, however, there no need line normalizations anyway. can disable them putting * -text
in .gitattributes
file (and removing lines below sets type of file text). that's alternative chose when ran problem, i'm not fan of version command scheme changing contents of files.
git
Comments
Post a Comment