Git add ошибка

  • Dpy3b

Столкнулся с этим впервые, другой проект нормально залился в репозиторий.
Вот порядок действий:

Захожу в локальную папку проекта
cd ~/project

Инициализирую гит
git init

Фоловлю файлы
git add .

И тут он пишет мне:

warning: LF will be replaced by CRLF in *file_name*
The file will have its original line endings in your working directory.

После чего выполняю коммит и он пишет:

On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:

В гите новичок. Гуглил, способы решения не подошли.


  • Вопрос задан

    более трёх лет назад

  • 35878 просмотров

Пригласить эксперта

Инициализируем новый репозиторий
git init

Добавляем файлы (все)
git add .

Если файлы не добавляются, то добавляем каждый вручную
git add README.md

Делаем коммит
git commit -m "First commit"

Пушим
git push -u origin master

warning: LF will be replaced by CRLF in *file_name*
The file will have its original line endings in your working directory.

Здесь всего-лишь говорится, что перенос строки будет дополнен возвратом каретки.

Связанно это с тем что переносы строк были в Unix-формате, так как дело происходило под Windows.
Простые решения:

Очень просто конвертировать переносы строк в Windows-формат помогает текстовый редактор Notepad++: Правка→EOL конверсия→Преобразовать в WIN-формат.
Подробнее.
Вручную преобразовать символы перевода строки из виндовых в линуксовые, открыть файл, еще раз визуально все проконтролировать и сохранить.
Быстро заменить CRLF на LF можно утилитой dos2unix, входящей в MINGW, с которым поставляется git для win32:

dos2unix.exe -f -D *file*


  • Показать ещё
    Загружается…

04 июн. 2023, в 01:35

1500 руб./за проект

04 июн. 2023, в 01:25

40000 руб./за проект

03 июн. 2023, в 23:42

1500 руб./за проект

Минуточку внимания

Пытаюсь добавить проект в git, создала .gitignore
произвела следующие действия:
git init
git status
git add .
и вот git add . у меня не прошел
пишет
error: ‘site_tests/’ does not have a commit checked out
fatal: adding files failed

site_tests — это просто папка, где у меня складируются автотесты проекта
уже перепробовала все, что смогла и все никак
причем, добавляла обычный .txt файл и загружала только его, и все получалось, но как только пытаюсь загрузить все — ничего не выходит

буду очень благодарна за помощь в моей проблеме

Эникейщик's user avatar

Эникейщик

25.1k7 золотых знаков30 серебряных знаков46 бронзовых знаков

задан 26 авг 2019 в 20:08

NOtAgoodProgger's user avatar

NOtAgoodProggerNOtAgoodProgger

431 золотой знак1 серебряный знак8 бронзовых знаков

14

У меня была подобная ситуация.

У меня папка в которой лежат куча файлов. И я хочу эту папку проиндексировать. Но вылетела ошибка:
error: ‘JS/’ does not have a commit checked out
fatal: adding files failed

Что я сделал:

  1. В папке JS/ у меня была скрытая папка .git/ ( которая отвечает за структуру Git-репозитория ) . Она была лишней и я ее удалил. Отмечу, что у меня была папка .git на уровне проекта (в папке my_project), а папка .git в папке JS была лишней.
  2. Затем согласно данной книги: Pro Git: Основы Git — Запись изменений в репозиторий .
    Сказано: «Команда git add принимает параметром путь к файлу или каталогу, если это каталог, команда рекурсивно добавляет все файлы из указанного каталога в индекс.».

То есть нужно для каталогов указывать путь:
Для меня команда выглядела так: git add C:UsersUsermy_projectJS , и все корректно проиндексировалось.

ответ дан 8 мая 2020 в 21:07

Тимур Оразалинов's user avatar

1

Столкнулся с такой же проблемой.
Как оказалось, я очень неудачно скопировал несколько файлов из другого проекта, и в одной из папок была папка .git.

После её удаления все заработало.

0xdb's user avatar

0xdb

51.4k194 золотых знака56 серебряных знаков233 бронзовых знака

ответ дан 5 окт 2021 в 20:21

Qwerty's user avatar

QwertyQwerty

696 бронзовых знаков

when I try to git add my files, I typed

git add <insert file names here>

That works correctly. However, when I try to do

git commit -a

My git repository tells me that it’s empty. What is outputted is:

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed) 
#
<insert name of files here>

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

Might anyone know the solution to this? Thanks.

asked Nov 12, 2012 at 6:48

user200081's user avatar

1

And you may also want to make sure you’re in the root of your project. I had that problem for a while on a Rails project a while back & then realized I was in the /config directory. Whoops! #noobmistake

answered Jul 23, 2013 at 14:09

Kyle Carlson's user avatar

Kyle CarlsonKyle Carlson

7,9275 gold badges35 silver badges43 bronze badges

4

The -a flag to git commit overwrites your staging area («index»). Look at what the man page says:

   -a, --all
       Tell the command to automatically stage files that have been modified
       and deleted, but new files you have not told git about are not
       affected.

A rule of thumb is to use a plain git commit when you have used git add. The command git commit -a is for when you want to commit every change in the repository but can’t bother to git add them.

PS. git add -A is useful: it adds all non-ignored new files in your working tree

answered Nov 12, 2012 at 7:02

opqdonut's user avatar

opqdonutopqdonut

5,10922 silver badges25 bronze badges

0

There may be directory called Main, If you can find directory called Main , there may be .git folder hidden into it.

If there is nothing else in Main directory, you may try deleting it and then re-run commands.

Hopefully it should work

You must be logged in to vote


8 replies

@idevGH

go to view on windows and check hidden files and folders, .git folder should show in that dir, delete and try running the command

@SHAKUURR

@huzaifa250

Hi will this going to work on linux too??

@piotrpalacz

Thank you very much for your solution because I’ve fought with this issue since yesterday!

@Krocsky

There may be directory called Main, If you can find directory called Main , there may be .git folder hidden into it.

If there is nothing else in Main directory, you may try deleting it and then re-run commands.

Hopefully it should work

Yo, i fixed my issue. Graceful thanks

Answer selected

In this article, we will see how to solve unable to index file Permission denied error which comes up during when we add the changes using git add command. It is not very often that when I run git add command then I would end up in getting an error but last night when I was trying to add my changes after updating the data excel sheet then I didn’t helped myself noticing the error which was also a sudden sock for me as I didn’t expected it.

But it did showed up due to my little mistake happened at that time which I am going to explain in below section. The same mistake also led me write this article so that it will help you folks as well if you are indeed also facing the same error. So without further delay let’s begin !!

Solved "git add shows unable to index file Permission denied" error

Also Read: How to Setup Passwordless Authentication for git push in GitHub

As I said earlier, when I tried to add my changes using git add command then I noticed unable to index file, Permission denied error on the output as you can also see below.

NOTE:

Please note that I am getting below error on my Git tool installed on Windows 10 System.

cyberithub@DESKTOP-PX1TGHA MINGW64 ~/Desktop/repo/atlantis-example (master)
$ git add .
error: open("~$data.xlsx"): Permission denied
error: unable to index file '~$data.xlsx'
fatal: adding files failed

While the above error could show due to many reasons but most of the time it is because the file in which you did the changes is still open and not yet closed. Hence this error. So to solve this, you just need to close the file and then try adding the changes again. This time you will notice that it did not throw that error again as you can see below.

cyberithub@DESKTOP-PX1TGHA MINGW64 ~/Desktop/repo/atlantis-example (master)
$ git add .

Now if you check and verify the status using git status command then you will notice that the changes are added successfully and hence the error is resolved now.

cyberithub@DESKTOP-PX1TGHA MINGW64 ~/Desktop/repo/atlantis-example (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: data.xlsx
modified: main.tf

Above case is shown for an excel sheet file but for you it might be different file opened in some code editor such Visual Studio Code, IntelliJ IDEA etc. In those cases also, you will see the same error. So to fix the error you need to do the same thing there as well. Just close the file in the code editor and then try to run git add again. It will surely work.

Most of the time above solution works however there are some cases in which above solution might not work and you still end up in getting that same error. In that case, you can check your user permission and see if you are allowed to run git add command. If it’s indeed a user permission issue then you can fix this by running git add command with sudo access. In some cases, this solves the problem as well.

Then there is another scenario that could be possible is that user don’t have enough permission to edit the file. This means that file is created by another user or the permission to the file is such that other users apart from owner of the file won’t able to perform any operation on that file. In that you can either change the user permission on that file by using chmod command or you can change the ownership of the file by using chown command.

Above solutions should be enough to solve your git add error as well. Hope it helped. Please let me know your feedback in the comment box !!

Понравилась статья? Поделить с друзьями:
  • Girbau коды ошибок
  • Ginzzu ошибка е1 плита
  • Gilgen ошибка e1000
  • Gilgen автоматические двери коды ошибок e2000
  • Gilgen автоматические двери коды ошибок 105