How can I configure sourcetree to ignore timestamp of a file and instead focus on when the code changes?
Asked by NathanG:

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).  
[](https://community.atlassian.com/t5/Sourcetree-questions/How-can-I-configure-sourcetree-to-ignore-timestamp-of-a-file-and/qaq-p/31145?attachment-id=2890){#link_11690f12b57c27}  
[](/tnckb94959/attachments/tnckb94959/sourcetree-questions/927/1/image2016-6-13%2012%3A45%3A36.png){#display_11690f12b57c27_0}  
[](https://community.atlassian.com/t5/Sourcetree-questions/How-can-I-configure-sourcetree-to-ignore-timestamp-of-a-file-and/qaq-p/31145?attachment-id=2891){#link_11690f12b57c27_0}  
[](/tnckb94959/attachments/tnckb94959/sourcetree-questions/927/2/image2016-6-13%2012%3A44%3A42.png){#display_11690f12b57c27_2}


Answers:
author: Tim Crall
body: 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.

comments: author: Seth
body: 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.


author: NathanG
body: 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.)


author: Geoff Joy
body: 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.


author: Geoff Joy
body: Forehead smack and DOH! You did say you copied the files.... jeeze I am so dumb.


author: NathanG
body: No changes for the base.py file:

```
C:\appsrv\bitbucket\DMID_Atlassian&gt;git diff lclapps/oppen/module/base.pywarning: 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&gt;git diff lclapps/oppen/module/confluence_db.pydiff --git a/lclapps/oppen/module/confluence_db.py b/lclapps/oppen/module/confluence_db.pyindex 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&gt;git diff --check lclapps/oppen/module/base.pywarning: 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&gt;git diff --raw lclapps/oppen/module/base.pywarning: 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&gt;git diff --raw lclapps/oppen/module/*.pywarning: 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.pywarning: 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&gt;git diff --stat lclapps/oppen/module/*.pywarning: 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&gt;git diff --summary lclapps/oppen/module/*.pywarning: 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&gt;git config --global core-autocrlferror: key does not contain a section: core-autocrlf
```


author: NathanG
body: 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\"
```


author: NathanG
body: 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.


author: QwazyWabbit
body: 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.


Tags: windows