Меню

No such file or directory git bash ошибка

I ran into this error, and found very little documentation on how to fix it online. I got the error by trying to run the command git add ., and received this response:

fatal: unable to stat ‘myPathToAFile’: No such file or directory

asked Jan 4, 2013 at 16:50

coder's user avatar

codercoder

10.4k17 gold badges71 silver badges125 bronze badges

1

To solve the problem, I removed the file from git, then re-added it by doing the following:

git rm "myPathToAFile"

git add .

git commit -am 'my commit'

Hope this helps someone else!

answered Jan 4, 2013 at 16:50

coder's user avatar

codercoder

10.4k17 gold badges71 silver badges125 bronze badges

1

answered Jul 2, 2015 at 11:03

Babu James's user avatar

Babu JamesBabu James

2,7134 gold badges32 silver badges50 bronze badges

2

Another cause for this problem on Windows might be reserved file names. I bumped on them when I tried to clone the Linux Kernel repository out of curiosity on my Windows 10 machine, and Git could not create aux.c and aux.h files.

So you cannot create any file (with any extension) or folder named: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, case insensitive.

See: https://learn.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions

answered Jul 25, 2018 at 15:54

Tejes's user avatar

TejesTejes

1451 silver badge10 bronze badges

None of the above worked for me.

Updating Git fixed the problem.

answered Sep 6, 2018 at 4:44

J.Tribbiani's user avatar

J.TribbianiJ.Tribbiani

4393 silver badges9 bronze badges

1

Similar to the comment by Tejes, I had this problem only with files called «aux.R», which I could not git pull onto a windows machine, while it works fine on my linux client.

I fixed it by renaming it to «auxiliary.R», works now without any problem.

answered May 13, 2020 at 14:35

Laurin Herbsthofer's user avatar

1

This problem can occur if your shell is working from a folder that does not exist in the currently checked out branch.

I was on a feature branch and was accidentally no longer using git from the root directory, but rather from a directory that only existed in that feature branch. When then checkouting to the main branch (using vs code rainbow ui), git would give me this error.

The solution was to cd .. back to the root directory of the git repo.

answered Dec 11, 2022 at 2:04

The Coding Wombat's user avatar

Последние комментарии

Иван Александрович

Иван Александрович

27.01.2023, 18:36

Здравствуйте, подскажите пожалуйста, как сделать так чтобы слайдер рассчитывал размер блока с картинкой не в момент загрузки страницы, а после открыти…

Слайдер для сайта на чистом CSS и JavaScript

485

Дмитрий

Дмитрий

27.01.2023, 11:04

«то использовать заполнители или сопровождать этот процесс какой-то анимацией.» — а как это примерно делается, у вас есть в уроках описание…

Получение и установка контента элементам в JavaScript

16

Александр Мальцев

Александр Мальцев

25.01.2023, 14:46

Да, на MODX 2.8.x аналогично.

Создание формы для сайта на MODX с использованием FormIt

439

Александр Мальцев

Александр Мальцев

23.01.2023, 06:53

Здравствуйте! Пожалуйста.
Если правильно понял задачу, то так:
const login = prompt(‘Введите логин?’);
if (login === null …

alert, prompt и confirm — диалоговые окна в JavaScript

29

Alexander_777

Alexander_777

22.01.2023, 20:30

Огромное Вам спасибо! Действительно, очень изящное решение!

А вообще, так сказать, для общего развития — существуют какие-то функции или алгоритмы д…

Ассоциативные массивы в JavaScript

47

dj_Nikita

dj_Nikita

21.01.2023, 14:05

Александр. А как настроить скрипты, чтобы получился простой чат, типа как на Youtube. Было бы классно, если бы было так: Когда заходишь с нового устро…

Простой чат-бот для сайта на чистом JavaScript

50

Dem0n1c

Dem0n1c

18.01.2023, 09:40

Добрый день, наверняка здесь присутствует ошибка.
Метод has позволяет поверить в объекте FormData наличия указанного ключа.
// данный метод вернёт tru…

FormData — Объект JavaScript для кодирования данных формы

1

David

David

16.01.2023, 17:14

Спасибо за ответ!
Один раз IP определился вот так: 2a01:4450:c100:b192:f195:566:e7b3
Это тоже может быть с этим связано?

Как в PHP узнать IP пользователя и определить его страну?

32

Игорь

Игорь

29.12.2022, 12:46

Здорово! Всего 3 строчки в html файле и работает реакт! А во всех обучающих видео зачем то
1) Формируют файл package.json
2) Cкачивают половину интер…

Что такое React и как он работает?

3

Виталий Алехин

Виталий Алехин

28.12.2022, 21:52

function input()
{
var x=new ItcSimpleSlider(«.itcss»)
let y=document.getElementsByTagName(«input»)[0].value;
const index …

Простой адаптивный слайдер для сайта на чистом JavaScript

260

Email-рассылка

Не пропустите свежие статьи и уроки, подпишитесь на информационную рассылку
«itchief.ru». Отправка писем на почту раз в неделю!

Подписаться

I’ve been trying to find out by this problem is happening, I’m using Windows 10 and this error occurs on Git Bash.

Whenever I run the cd command to change the directory, I get the following error:

cat: /dev/fd/63: No such file or directory

However, the cd command still works, as it changes the directory, but this message appears below the command every single time, and I’m not sure why, and I can’t find anything related to this problem online, specially with Windows 10.

I have a Ubuntu WSL, and when I use it to access /dev/fd/ I can see several numbers, but 63 is not present, and touch /dev/fd/63 does not work.

This started happening recently, I believe right when I tried installing RVM on my machine, and followed this instructions: https://rvm.io/rvm/install

And I ran this command on Git Bash

curl -sSL https://get.rvm.io | bash

The install seems to have worked, however that message has been popping up everytime on cd, only on Git Bash, and not on Ubuntu WSL.

Thanks

I was following through the git documentation and installed Git using source code package. Now, after installing Git, I want to update it (Though it might be unnecessary at this time, I simply want to try and make sure it works). I ran the command git clone git://git.kernel.org/pub/scm/git/git.git and it returned error -bash: /usr/bin/git: No such file or directory. Reason might be obvious, since for installing git, I used the command make prefix=/usr/local install which installed Git in /usr/local/bin/git

Now, how to fix this?

I tried the same git clone command with --git-dir=/usr/local/bin/git which returned the same error -bash: /usr/bin/git: No such file or directory

Rui F Ribeiro's user avatar

Rui F Ribeiro

54.8k26 gold badges143 silver badges220 bronze badges

asked Sep 16, 2013 at 14:44

Gokul's user avatar

What does hash say? Did you have a /usr/bin/git previously and then removed it? That would lead to bash: /usr/bin/git: No such file or directory while hash still believes git to be there.

The solution in this case would be to either use a new shell. Or for each shell with the old hash, reset it using hash -r.

answered Sep 16, 2013 at 14:52

frostschutz's user avatar

frostschutzfrostschutz

44.4k5 gold badges106 silver badges147 bronze badges

5

Go back and rebuild it without the argument to make. If you want to set the prefix directory, you need to do it with configure, but it defaults to /usr/local anyhow.

answered Sep 16, 2013 at 14:52

psusi's user avatar

psusipsusi

16.7k3 gold badges37 silver badges47 bronze badges

One of the fun things about working with Git on Windows is that you’re often
at the mercy of the filesystem underneath you, and this crops up in some
entertaining ways:

  • even though NTFS supports running as a case sensitive filesystem, the Win32
    subsystem does not support filenames that differ by case sensitivty only
  • some characters are not permitted by Win32 subsystem APIs — and I refer back to
    this link
    regularly to remind myself of this.

Even in the age of running Linux on Windows,
these compatibility issues are not going away any time soon, and taking a
repository and running it on Windows can be problematic, so the rest of this
post is about repairing these repositories so they are not tied to a particular
filesystem.

Please note

  • All of these operations are being run inside Git Bash that ships with Git
    for Windows — if you are trying to perform the same actions in a different
    shell they’re likely to fail.
  • These instructions are tailored to one repository. You’ll need to adapt
    these based on the problem file paths you encounter in your situation.
  • This repository has been fixed, so you probably won’t be able to
    replicate the same behaviour by running the exact same commands either.

The Scene — A Failing Clone

You might have stumbled upon an error like this when cloning down someone else’s
repository:

$ git clone https://github.com/MCanterel/Dual_Brains
Cloning into 'Dual_Brains'...
remote: Counting objects: 12023, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 12023 (delta 9), reused 14 (delta 4), pack-reused 12000
Receiving objects: 100% (12023/12023), 56.77 MiB | 6.63 MiB/s, done.
Resolving deltas: 100% (5891/5891), done.
error: unable to create file test-files/SavedDataOpenBCI-RAW-aaron+eva.txt: No such file or directory
error: unable to create file test-files/SavedDataOpenBCI-RAW-friday_test.txt: No such file or directory
Checking out files: 100% (9136/9136), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

So here is where Git is actually falling over:

error: unable to create file test-files/SavedDataOpenBCI-RAW-aaron+eva.txt: No such file or directory
error: unable to create file test-files/SavedDataOpenBCI-RAW-friday_test.txt: No such file or directory

Did you read the link
above about valid file path characters? I’ll quote the relevant part here:

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

  • The following reserved characters:

    • < (less than)
    • (greater than)

    • : (colon)
    • » (double quote)
    • / (forward slash)
    • (backslash)
    • | (vertical bar or pipe)
    • ? (question mark)
      • (asterisk)

So we can’t use as a path in Windows, but we have a repository that has some
existing content using this character. That’s what we need to fix here.

At this point you could look inside the newly created repository on disk and
try to salvage things. I wouldn’t recommend this approach because of this error
message further down.

fatal: unable to checkout working tree

The working tree is the files on disk associated with the current branch (either
the default branch or whatever branch you wanted to initially checkout). And
with that in an unknown state, there is only pain ahead. Let’s try a different
way.

Part 1 — Fix The Problem Checkout

Because git clone fails I used this set of commands to emulate a clone
operation:

$ git init test-repo
$ cd test-repo
$ git remote add origin https://github.com/MCanterel/Dual_Brains -f

This gets us to a usable repository state, but these problem files still need
addressing:

$ git checkout origin/master -f
error: unable to create file test-files/SavedDataOpenBCI-RAW-aaron+eva.txt: No such file or directory
error: unable to create file test-files/SavedDataOpenBCI-RAW-friday_test.txt: No such file or directory
Checking out files: 100% (9136/9136), done.
Note: checking out 'origin/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 0cbfb99 Merge remote-tracking branch 'refs/remotes/upstream/master'

I’m going to just remove those so I have something to work with:

$ git checkout -b fix-path-issue-with-invalid-files
Switched to a new branch 'fix-path-issue-with-invalid-files'
D       "test-files/SavedData\OpenBCI-RAW-aaron+eva.txt"
D       "test-files/SavedData\OpenBCI-RAW-friday_test.txt"

$ git status
On branch fix-path-issue-with-invalid-files
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    "test-files/SavedData\OpenBCI-RAW-aaron+eva.txt"
        deleted:    "test-files/SavedData\OpenBCI-RAW-friday_test.txt"

no changes added to commit (use "git add" and/or "git commit -a")

$ git add .

$ git status
On branch fix-path-issue-with-invalid-files
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    "test-files/SavedData\OpenBCI-RAW-aaron+eva.txt"
        deleted:    "test-files/SavedData\OpenBCI-RAW-friday_test.txt"

$ git commit -m "removed files with invalid paths"
[fix-path-issue-with-invalid-files 726d35a] removed files with invalid paths
 2 files changed, 131880 deletions(-)
 delete mode 100644 "test-files/SavedData\OpenBCI-RAW-aaron+eva.txt"
 delete mode 100644 "test-files/SavedData\OpenBCI-RAW-friday_test.txt"

Now we have no problems checking out this branch, but we did this by removing
the problem paths from the repository. If we want to be able to access those
files in the repository we have more work to do.

Part 2 — Put The Files Back

Git keeps a history of all the file contents for all commits in it’s .git
folder, and we can explore this using various Git plumbing commands.

We can use git ls-tree to read the tree contents of a given hash and
find the original contents of the files we just removed:

$ git ls-tree origin/master
100644 blob 4fda0922d502719782c70810a6d5ddb1c9bdd14d    .gitignore
040000 tree b39c2cabf1b81dba6e7b625ffa2d9e4535e7421f    Dual_Brains_Visualization
100644 blob fa4410c60ac7d6becebdbe43f5560976ae1d207b    README.md
040000 tree 8974c3cb0ae7f8bc05fc891cf481d58235ae5c83    aaron_test_data
040000 tree 68d65ff67f213859f124ed492428eebdb7a5d1ec    drafts
040000 tree 0ca5bae4b0173c9b2f47893136a6d0b299006378    images
040000 tree 7fe38978bb6d446ee4ac3d68a2a3ff006685c8ed    python
100644 blob ca9d99d426f059fdf0c377552d196a22ae2ff47a    requirements.txt
040000 tree e2a3b7648b57746e68ced4f881f193df05a2341f    test-files

Git stores each commit as a tree, and a tree can contain blobs (the file
contents) or other trees. Each entry in a tree also needs a mode (for representing
permissions) and a path. If you squint at this, it’s not unlike a filesystem
representation as a data structure.

The two problem file paths are under test-files so we’ll use the e2a3b7648b57746e68ced4f881f193df05a2341f
hash from the previous command and run git ls-tree again:

$ git ls-tree e2a3b7648b57746e68ced4f881f193df05a2341f
040000 tree 35266afd270f2cf429dd753ab695aacf03ee68d8    Filtered_Data
040000 tree 97ab85ca7728e41e080fe9a9128227d2828108d9    RAW_data_only
040000 tree f55abe3ef151d7209c6cce61878823dc6b2f8801    RAW_output
100644 blob 5020200c10e545c19002f4878c2b6686035f10b0    "SavedData\OpenBCI-RAW-aaron+eva.txt"
100644 blob 0680d8432628eb071aa2c643f11fe8984df6e972    "SavedData\OpenBCI-RAW-friday_test.txt"
100644 blob becc5ab499fb0954c72026fdd78c3517694f5ffa    eeg_filter.m

Excellent, we can see the problem file paths and they correlate to two blobs 5020200c10e545c19002f4878c2b6686035f10b0 and 0680d8432628eb071aa2c643f11fe8984df6e972. These identifiers can be used to find the file contents.

The next step is to read out the contents of those blobs and write them to new
files. I’m going to also create the SavedData directory name again because I
think that was the intent here and someone just used the wrong slash and got
away with it.

$ mkdir test-files/SavedData/

$ git cat-file -p 5020200c10e545c19002f4878c2b6686035f10b0 > test-files/SavedData/OpenBCI-RAW-aaron+eva.txt

$ git cat-file -p 0680d8432628eb071aa2c643f11fe8984df6e972 > test-files/SavedData/OpenBCI-RAW-friday_test.txt

Now we have two new files to commit:

$ git status
On branch fix-path-issue-with-invalid-files
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        test-files/SavedData/

nothing added to commit but untracked files present (use "git add" to track)

$ git add .
warning: LF will be replaced by CRLF in test-files/SavedData/OpenBCI-RAW-aaron+eva.txt.
The file will have its original line endings in your working directory.
gwarning: LF will be replaced by CRLF in test-files/SavedData/OpenBCI-RAW-friday_test.txt.
The file will have its original line endings in your working directory.

I’m not worried about the line ending warning here, and I can confirm this is
accurate once we’ve completed these steps.

Now we can commit these files to the new path:

$ git status
On branch fix-path-issue-with-invalid-files
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   test-files/SavedData/OpenBCI-RAW-aaron+eva.txt
        new file:   test-files/SavedData/OpenBCI-RAW-friday_test.txt


$ git commit -m "add the new files with the correct paths"
[fix-path-issue-with-invalid-files d2a39b6] add the new files with the correct paths
 2 files changed, 131880 insertions(+)
 create mode 100644 test-files/SavedData/OpenBCI-RAW-aaron+eva.txt
 create mode 100644 test-files/SavedData/OpenBCI-RAW-friday_test.txt

Now we have a branch that can be cloned on Windows safely.

Part 3 — Verification

To confirm that line ending warning was a non-issue, I can run the same git ls-tree
command from earlier and confirm the new blobs are unchanged:

$ git ls-tree HEAD
100644 blob 4fda0922d502719782c70810a6d5ddb1c9bdd14d    .gitignore
040000 tree b39c2cabf1b81dba6e7b625ffa2d9e4535e7421f    Dual_Brains_Visualization
100644 blob fa4410c60ac7d6becebdbe43f5560976ae1d207b    README.md
040000 tree 8974c3cb0ae7f8bc05fc891cf481d58235ae5c83    aaron_test_data
040000 tree 68d65ff67f213859f124ed492428eebdb7a5d1ec    drafts
040000 tree 0ca5bae4b0173c9b2f47893136a6d0b299006378    images
040000 tree 7fe38978bb6d446ee4ac3d68a2a3ff006685c8ed    python
100644 blob ca9d99d426f059fdf0c377552d196a22ae2ff47a    requirements.txt
040000 tree 7544e5996262a7fc5017f182790550ab51f92429    test-files

$ git ls-tree 7544e5996262a7fc5017f182790550ab51f92429
040000 tree 35266afd270f2cf429dd753ab695aacf03ee68d8    Filtered_Data
040000 tree 97ab85ca7728e41e080fe9a9128227d2828108d9    RAW_data_only
040000 tree f55abe3ef151d7209c6cce61878823dc6b2f8801    RAW_output
040000 tree 8974c3cb0ae7f8bc05fc891cf481d58235ae5c83    SavedData
100644 blob becc5ab499fb0954c72026fdd78c3517694f5ffa    eeg_filter.m

$ git ls-tree 8974c3cb0ae7f8bc05fc891cf481d58235ae5c83
100644 blob 5020200c10e545c19002f4878c2b6686035f10b0    OpenBCI-RAW-aaron+eva.txt
100644 blob 0680d8432628eb071aa2c643f11fe8984df6e972    OpenBCI-RAW-friday_test.txt

The two files are at the expected new location but still have the old blob hash.

To confirm the clone has been fixed, I cloned down my fork and ask it to
checkout this branch:

$ git clone -b fix-path-issue-with-invalid-files https://github.com/shiftkey/Dual_Brains my-fork
Cloning into 'my-fork'...
remote: Counting objects: 12028, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 12028 (delta 11), reused 17 (delta 5), pack-reused 12000
Receiving objects: 100% (12028/12028), 56.77 MiB | 7.52 MiB/s, done.
Resolving deltas: 100% (5893/5893), done.
Checking out files: 100% (9136/9136), done.

$ cd my-fork/

$ git status
On branch fix-path-issue-with-invalid-files
Your branch is up to date with 'origin/fix-path-issue-with-invalid-files'.

nothing to commit, working tree clean

Now, you just need to merge this branch into the default branch and everyone
will benefit from this change.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • No such file or directory compilation terminated ошибка компиляции
  • No such file or directory codeblocks ошибка