Why does one file in my project think its completely being changed?

So I'm using source tree and I'm working on a website, however 1 of my JS files ALWAYS treats the whole file as a single hunk. Hunk 1: Lines 0-0 It shows the first line as removed, then the whole file in white then the first line in green and the whole file in white. So its impossible to review what changes I made, discard or change individual hunks/lines. No other file is doing this and its only this file. It also appears this way in bitbucket so without doing a side-by-side diff I can't see what changes were done. Why is this happening? What steps should I take to resolve this?

2 answers

I would suspect white-space changes, possibly line-endings. Is SourceTree configured to show whitespace changes in the diff panel?

Yes, if I add a few empty lines to a normal files it'll show as new empty lines in source tree.

By "line-endings", I don't mean extra newlines, I mean the different byte sequences that can be used to signify a new line based on the source OS. http://en.wikipedia.org/wiki/Newline

If you switch sourcetree to ignore whitespace, you should be able to get a useable diff.

So I actually checked the settings and it's already set to ignore white space, I was testing with new lines.

FYI SourceTree's diff panel doesn't seem to have a clue about displaying files that use Classic Mac line endings.

FYI if you set a file to be executable it will show as changed but without showing any lines have actually changed.

If its the line endings why is only one file effected? How do I change this file to a crlf endings? If its executable how to a revert that?

I had the same problem, Hunk 1: lines 0-0 and it would not show updates in the file.  I was able to solve the problem by copying the code, deleting the (php) file in question, creating it again fresh, and pasting the code back in. YMMV.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

561 views 1 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you