0

I have created a new repository in BitBucket Server, and it is populated and in use. However, several of our users (myself included) are having a problem where unexpected changes are appearing on checkout. It does not appear on every checkout, only sporadically.

The changes appear to be a complete rewrite of the file(s) in question. git diff does not show, for example, that all line endings have changed. We are also using SVN Mirror to bring in changes from our older subversion repository on trunk -> master. Everyone is using 2.14 version of git on Windows.

The following commands will fix it temporarily, but it inevitably comes back

git rm --cache -r git reset --hard 

Example:

MINGW64 /c/code/git/repo (master) $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean MINGW64 /c/code/git/repo (master) $ git checkout - Switched to branch 'dev/test_branch' MINGW64 /c/code/git/repo (dev/test_branch) $ git status On branch dev/test_branch nothing to commit, working tree clean MINGW64 /c/code/git/repo (dev/test_branch) $ git checkout - Switched to branch 'master' Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) MINGW64 /c/code/git/repo (master) $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: <snip-filename>.java modified: <snip-filename2>.java ... etc ... modified: <snip-lastfilename>.java no changes added to commit (use "git add" and/or "git commit -a") 

Edit: Checking git diff -w to exclude whitespace changes shows no differences, so it definitely appears to be eol related.

10
  • Have you diff'd the changes? It could be file permissions. If so, see stackoverflow.com/questions/1580596/…. Commented Nov 10, 2017 at 15:29
  • When I use git diff it is showing as similar to @@ -1,539, ~1,539 @@ -<code> -<code> +<code> +<code> How would I tell from this if it is file permissions please? Commented Nov 10, 2017 at 15:43
  • Ah, I don't think that's permission issues, as you won't have code changes in the diff, you would see what the file permissions where of each file before and after. Could it be file encoding? Commented Nov 10, 2017 at 15:46
  • They're just standard java code, there is nothing special about them. The files showing as uncommitted do appear to be files that have recently had commits (on origin) Commented Nov 10, 2017 at 15:48
  • 1
    This really does look like CR/LF line ending issues, or perhaps some sort of related clean/smudge item. It's possible someone mistakenly committed the files with actual CR-LF endings inside them, and your Git is cleaning that up, replacing the endings with LF-only, which then shows up as a diff even though you are doing everything right. Commented Nov 10, 2017 at 18:35

1 Answer 1

1

For this issue, it ended up being due to Subversion mirroring. When enabled, the line endings coming from Subversion were not corrected automatically, and so had their original eol. With the GIT repository set either through .gitattributes, or through a user's default settings, to automatically correct line endings, this would cause a mismatch where the original line ending was CRLF, and the updated version just LF.

This was identified by using

git diff --ignore-space-at-eol 

which showed no differences to the previous version.

The solution was to commit and push the line-ending adjusted files into GIT. This then mirrored to Subversion, and put them back into sync again.

For more information, I found a very useful guide here: https://help.github.com/articles/dealing-with-line-endings/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.