Reputation: 1456
I am trying to take a git clone from a particular branch of my bitbucket repository using the below command:
git clone <url> --branch <branchname>
.
However, I am getting the below error while taking the clone:
error:unable to create file foldername/nodemodules/......: Filename too long.
I tried resolving this by running the below command in my git cmd
git config --system core.longpaths true
.
But I am getting:
error: could not lock config file c://.gitconfig: Permission denied error: could not lock config file c://.gitconfig: Invalid argument.
How do I solve these two errors?
Upvotes: 89
Views: 186439
Reputation: 23
This issue usually comes for Windows when you have large files to be cloned, and Windows have some size restrictions while clonning, So you can run below Global command to allow it clone longpath files
git config --global core.longpaths true
Upvotes: 0
Reputation: 1
Run following command:
git config --system --get core.longpaths
You can check if the path was correctly set to true by running following command in git bash:
git config --list --system core.longpaths=true
Upvotes: 0
Reputation: 21
Adding longpaths = true under [core] followed by Runnig git reset --hard origin/xxx from Git Bash. This worked for me.
Upvotes: 2
Reputation: 421
Instead of git config --system core.longpaths true
try:
git config --global core.longpaths true
--system
will set the variables for all users on the system, but what you are looking for is to the set it for currently logged in user.
Upvotes: 41
Reputation: 557
You can try setting long path with command (as Administrator):
git config --system core.longpaths true
Upvotes: 13
Reputation: 81
I was not having admin rights. So I had to go to config file in .git folder (hidden) in the same folder that you started the clone in local machine .
Then add longpaths = true
under [core]
.Run git reset --hard origin/xxx
from Git Bash. This worked for me.
Upvotes: 2
Reputation: 159
If command git config core.longpaths true
not worked then try changing it manually.
Go to .git
folder of your project (make sure you are enabled hidden items view in file explorer) and Open the config
file. File content will look like below
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = https://<domain>/scm/<project>/<repo>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Add longpaths = true
property manually under [core]
section. Save it and try pulling the code from fresh git bash session. It will solve the issue.
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
longpaths = true
Upvotes: 6
Reputation: 11
Basically we need to set a variable "longpaths" as true in our local git config file under core section.
You can navigate to it at path
<git-repo>\.git\config
alternatively you can clone your code using git bash with below command
git clone -c core.longpaths=true <repo-url>
Upvotes: 1
Reputation: 41755
git config --system core.longpaths true
Another way (only for this clone):
git clone -c core.longpaths=true <repo-url>
Upvotes: 190
Reputation: 1157
On Windows there is a maximum file name length limit of 260 characters.
See https://superuser.com/questions/811146/windows-7-file-name-length-limited-to-129-characters for how to remove it.
Upvotes: 2