I have a production server and sometimes I need to copy the files down to my local machine and commit any changes to Bitbucket (I have a very similar issue to this one: https://answers.atlassian.com/questions/38855280 )
When I copy all the files from production to my local machine, it seems that sourcetree thinks all the files have changed when in actuality only a few have changed.
When I click most of the files in the "unstaged files" area it shows no changes:
image2016-6-13 12:45:36.png
How can I get sourcetree to ignore these files (there are hundreds of them in my unstaged files panel).
As we mentioned on the question you linked to, this is almost always the result of a difference in line-endings (Windows CRLF vs Unix LF) in the files.
To help confirm this, you can go to the dropdown above the diff view, and set it to "show whitespace changes". If it then behaves like ALL lines have changed, it is definitely line endings.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I still get the same as the picture on the original post.... nothing shows up in the diff... (even when "show whitespace" is selected.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is strange. If the line endings were the cause it would definitely show up as all lines removed followed by all lines added.
Let's ask GIT what it sees, SourceTree is only a GUI for GIT so it would be GIT telling ST what's changed. Open a console to the working directory and type "git status" for a list of all the modified files, this is where ST gets it's unstaged list.
Next, sample a changed file with "git diff filename.ext" and see what it prints for differences.
git diff --check filename.ext will tell you if the change is purely due to whitespace. No message from get means it's not a whitespace change.
git diff --raw *.py will tell you the status of the change, M for modified, C for copied, etc.
git diff --stat *.py will print a bar graph per file of your insertion/deletions. If insertions == deletions we're dealing with a line-ending problem. If you glob the file names git will automatically pipe more so either spacebar for more or q to quit the list.
git diff --summary *.py will show you the files added/deleted/copied/renamed according to git but not merely internally changed as in line add/delete.
While were at it, type git config --global core-autocrlf and if it returns a blank line it's not set, and that's probably a good setting.
As far as I know, GIT doesn't depend on timestamps to know if a file has changed. It parses the file in the background per it's internal rule set and knows if the file has actually changed and which lines have changed. Somewhere a rule has determined the files have changed. These probes should give a clue as to why.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No changes for the base.py file:
C:\appsrv\bitbucket\DMID_Atlassian>git diff lclapps/oppen/module/base.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory.
Other files do have changes:
C:\appsrv\bitbucket\DMID_Atlassian>git diff lclapps/oppen/module/confluence_db.py diff --git a/lclapps/oppen/module/confluence_db.py b/lclapps/oppen/module/confluence_db.py index 482eb96..3c63e42 100755 --- a/lclapps/oppen/module/confluence_db.py +++ b/lclapps/oppen/module/confluence_db.py @@ -5,33 +5,4 @@ def get_connection(): return psycopg2.connect("dbname=confluence user=automation password=automation") if __name__ == "__main__": - BANDANAKEY = 'atlassian.confluence.smtp.mail.accounts' - query = """
Nothing is shown when adding --check:
C:\appsrv\bitbucket\DMID_Atlassian>git diff --check lclapps/oppen/module/base.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory.
The --raw flag shows some additional info:
C:\appsrv\bitbucket\DMID_Atlassian>git diff --raw lclapps/oppen/module/base.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory. C:\appsrv\bitbucket\DMID_Atlassian>git diff --raw lclapps/oppen/module/*.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/base_test.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/confluence.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/jira_db.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/job_module.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oncall.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oracle.py. The file will have its original line endings in your working directory. :100755 100755 3475a4c... 0000000... M lclapps/oppen/module/autosys_job.py :100755 100755 482eb96... 0000000... M lclapps/oppen/module/confluence_db.py :100644 100644 a3acc87... 0000000... M lclapps/oppen/module/jira.py warning: LF will be replaced by CRLF in lclapps/oppen/module/read_log_file.py. The file will have its original line endings in your working directory.
Differing number of insertions/deletions:
C:\appsrv\bitbucket\DMID_Atlassian>git diff --stat lclapps/oppen/module/*.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/base_test.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/confluence.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/jira_db.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/job_module.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oncall.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oracle.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/read_log_file.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/autosys_job.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/confluence_db.py. The file will have its original line endings in your working directory. lclapps/oppen/module/autosys_job.py | 10 - lclapps/oppen/module/confluence_db.py | 31 +-- lclapps/oppen/module/jira.py | 380 ++++++++++++++++++---------------- 3 files changed, 205 insertions(+), 216 deletions(-) warning: LF will be replaced by CRLF in lclapps/oppen/module/jira.py. The file will have its original line endings in your working directory.
Summary:
C:\appsrv\bitbucket\DMID_Atlassian>git diff --summary lclapps/oppen/module/*.py warning: LF will be replaced by CRLF in lclapps/oppen/module/base.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/base_test.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/confluence.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/jira_db.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/job_module.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oncall.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/oracle.py. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in lclapps/oppen/module/read_log_file.py. The file will have its original line endings in your working directory.
I get an error when setting the global config:
C:\appsrv\bitbucket\DMID_Atlassian>git config --global core-autocrlf error: key does not contain a section: core-autocrlf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just opened up my .gitconfig in my user directory and saw this:
[core] autocrlf = true [difftool "sourcetree"] cmd = 'C:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe' \"$LOCAL\" \"$REMOTE\" cmd = 'C:/Program
I changed it to this and saved:
[core] autocrlf = true [difftool "sourcetree"] cmd = 'C:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe' \"$LOCAL\" \"$REMOTE\"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I changed my .gitconfig to this and now it is working:
[core] autocrlf = false [difftool "sourcetree"] cmd = 'C:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe' \"$LOCAL\" \"$REMOTE\"
So, indeed it was the autocrlf! Turning it off fixed it, likely because when I copied the files from production (a linux server), all the text files had LF line endings... and since my workstation is windows and with autocrlf on, git was noticing a difference... so indeed, it appears this was the same problem as the linked post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed, it was the line endings. Glad you solved it.
Also note, the command is git config --get core.autocrlf with a dot following core, not a dash.
I'd now look for a method of transferring the files from Linux to Windows with line ending translation so you can preserve your CRLF in Windows and let LF work in Linux, the transfer to your remote will then occur with translation as appropriate from each type of client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.