Staging files with to long filenames (260+) stages the file for delete instead of modify

I'm using windows 7 and sourcetree 1.9.10.0  with following in my git config file

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
core.longpaths=true
user.name=myuser
user.email=myuser@mail.com
core.excludesfile=C:\Users\myuser\Documents\gitignore_global.txt

You notice the core.longpaths option there.  I can checkout my project from bitbucket perfectly and work on it in inteliJ.  However when I try to stage a file longer then 260 chars sourcetree stages it for delete.  I can commit the file just fine with command line git or even in inteliJ.

Is this a bug in the current sourcetree or can this be fixed with a parameter ?  This is a very dangerous development cause if a code reviewer misses this in one pull request the project code if not unit tested properly could get messed up.

2 answers

1 vote

Hi Kenny! The 260 character file path limit comes from the Windows side and was fixed on Windows 10, you can read more about it at Why does the 260 character path limit exist in Windows?

Regarding the long name files being staged for deletion, you can follow these steps to fix the issue:

  • Download and install the latest Git 
  • Enable longpaths with ‘git config core.longpaths true’
  • Make sure that SourceTree is using the System’s Git and not the embedded one. You can check that at Tools > Options > Git > Use System Git

After this, you'll be warned with a “Filename too long” message instead of having your files staged for deletion. 

Thanks to Matej Drolc for putting this together in his blog msysgit-longpath. I'll also open a bug ticket to see if we can get SourceTree's embedded Git to respect the longpath settings.

Hope this helps, Kenny :)

Cheers,

Ana

Hey Ana,

I followed all the steps but the problem persists.  This is my current git config

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
diff.astextplain.textconv=astextplain
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
credential.helper=manager
user.name=<<My User>>
user.email=<<My Email>>
core.excludesfile=C:\Users\MyUser\Documents\gitignore_global.txt
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.longpaths=true
remote.origin.url=<< my remote orgin url >>
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.develop.remote=origin
branch.develop.merge=refs/heads/develop
branch.master.remote=origin
branch.master.merge=refs/heads/master
gitflow.branch.master=master
gitflow.branch.develop=develop
gitflow.prefix.feature=feature/
gitflow.prefix.release=release/
gitflow.prefix.hotfix=hotfix/
gitflow.prefix.support=support/

This is my git version now

$ git --version
git version 2.12.2.windows.2

I double checked and sourcetree is using the system git instead of the embedded git, I checked three times to be sure.  I also fully rebooted my machine cause well ... windows ... but the problem still persists.  I can commit and push fine using git bash just sourcetree keeps staging for delete.

Maybe it just can't work on windows 7 ?

Hi Kenny, I've submitted a bug report for that, you can track it at SRCTREEWIN-7075. Please watch that pages for updates on this issue :)

Edit: Realised there was already a ticket for that, please follow SRCTREEWIN-6606.

Cheers!

Ana

The problem of too long file names can be solved easily with programs like Long Path Tool.

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...

568 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