user6123723
user6123723

Reputation: 11136

Git add command fails saying "filename too long"

I initialized a git repository to add a local instance of Oracle Weblogic server (Yes!) to version it using git.

The oracle files are in c:\Oracle. So I need to add the same to git

I issued the following commands

git init (in c:\ which has the Oracle directory)

added a .gitignore dir in c:\ and ignored all the directories in c:\ except for Oracle

Then ran a 'git status' to see the status. As expected, it showed the following

C:\>git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .gitignore
#       Oracle/
nothing added to commit but untracked files present (use "git add" to track)

Now, I did a git add * The above command as expected threw some verbose output showing the files that are being added and ended with the following (tail of the command output is displayed below)

....
base_domain/servers/AdminServer/tmp/.appmergegen_1387484701373_liferay-portal-6.
1.30-ee-ga3-20130812170130063.war/html/VAADIN/themes/runo/tree/tree.css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Oracle/Middleware/user_projects/domains/
base_domain/servers/AdminServer/tmp/.appmergegen_1387484701373_liferay-portal-6.
1.30-ee-ga3-20130812170130063.war/html/VAADIN/themes/runo/window/window.css.
The file will have its original line endings in your working directory.
fatal: unable to stat 'Oracle/Middleware/user_projects/domains/base_domain/serve
rs/AdminServer/tmp/.appmergegen_1387484701373_liferay-portal-6.1.30-ee-ga3-20130
812170130063.war/html/VAADIN/widgetsets/com.vaadin.portal.gwt.PortalDefaultWidge
tSet/043D1FB3F694D0D6D3ACFB33DB80E43D.cache.html': Filename too long

I then issued a git status to see if the files are added

C:\>git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .gitignore
#       Oracle/
nothing added to commit but untracked files present (use "git add" to track)

So it appears like nothing has been added. Is the folder too big for git?

I've tried Bazaar and its GUI controls freeze whenever I work with the repository. Now I'm trying Mercurial to see if it can handle it.

Upvotes: 11

Views: 7539

Answers (4)

nehem
nehem

Reputation: 13662

Remap to shorter drive like this subst X: C:\<__relevant_lengthy_path__>\

--

I had a similar encounter which confirmed the 260 char limitation of Max Path length for Windows

The way I handled was using SUBST (substitute) command which maps any lengthy folder to a single letter drive, for example subst X: C:\<__relevant_lengthy_path__>\

However in your case it is big unfortunate that you had git inited in just C:\ which is unusual & brave:)

Upvotes: 8

Baz
Baz

Reputation: 2297

Cygwin to the rescue! Running the same comands through Cygwin's Git worked for me.

Upvotes: 6

kostix
kostix

Reputation: 55543

The problem is Windows-specific: Git for Windows does not currently use that Win32 API hack of prepending \\?\ to pathnames to overcome the standard pathname length limit of 260 characters, and your pathname is 9 characters longer than the limit.

Upvotes: 4

janos
janos

Reputation: 124724

I seriously doubt you really need that .../tmp/... directory. git add fails when there are any errors. If there is a problem adding any of the files you specified, nothing will be added.

I suggest to ignore the tmp directory:

echo tmp >> .gitignore
git add .

This will ignore all tmp directories in the project. If you want to ignore specific tmp directories, you can specify their full path:

echo path/to/AdminServer/tmp >> .gitignore
git add .

Since the long filenames are in that tmp directory in your sample output, by ignoring the directory the git add . should work.

Upvotes: 6

Related Questions