cannot add to the index - missing --add option?
Asked Answered
H

8

12

I'm using Github Desktop and tried pushing a new project into a React_Native repository, however when I try committing the code I'm prompted with "cannot add to the index - missing --add option?", I noticed that this problem occurs after I run "expo init client" to initiate my program. Any help is greatly appreciated. enter image description here

Hiccup answered 5/12, 2021 at 19:6 Comment(0)
L
15

I had the same problem.

What fixed it for me was I went into the folder using file explorer. Under the view tab, I checked the hidden items box. Then I deleted the .git file.

edit: see @opcode's comment.

Levison answered 2/1, 2022 at 22:8 Comment(3)
Deleting the .git folder worked for me as well. ThanksFarmstead
Just to be clear, for people coming from Google. Don't just delete your git folder but check if you have another .git subfolder first. gitnception causes this error too basically.Inharmonious
I some how had a folder with same project name inside my project and was causing this issue. Solution for me was to delete that folder and everything worked like magic. I was working on a Laravel project with a lot of folders so knowing that a folder like this exits was kinda hard to do.Nonscheduled
P
5

I was very silly and hadn't committed the file yet. Git has to be tracking it first so the files you apply this to can't be new, must be committed first

Piselli answered 9/2, 2022 at 4:3 Comment(0)
G
1

there's a another .git folder nested inside your project. Go and delete that folder to make it work.

Grajeda answered 19/3, 2022 at 12:16 Comment(0)
R
0

Look at the first error first, that's likely what's causing the other ones. It's saying that that directory (John_Deere/client/) was not found. That path probably doesn't exist any morel maybe you moved some folders around or something? Try adjusting the expected path and see if that works.

Restharrow answered 5/12, 2021 at 19:9 Comment(2)
thanks for the suggestion, the files and folders are still present in the correct repository folder, has to be something else, my guess is that the problem may relate to react-nativeHiccup
@Hiccup -- That's not likely because even the second error is saying that it can't add that directory to the index (probably because there's some problem with that directory).Fransiscafransisco
W
0

In my case (same error), i had php container running, with project folder connected as volume to my local storage. Previously I created git repo inside this project folder and this action left some hidden files inside. In my case even 'empty' folder resulted in this error occuring (as i presume due to hidden files still being present). Still not 100% sure what did the trick for me but my guess is on deleting hidden '.git' file (in my case from container cli)

Waterish answered 6/12, 2021 at 8:52 Comment(0)
P
0

I agree that checking the folder for hidden files - or oddly named files - is a good start to troubleshooting this problem.

Alternatively, you could create a new folder in the destination repository and copy over the specific files you want there - that will likely address the issue for you, too.

Petrosal answered 7/12, 2021 at 16:14 Comment(0)
G
0

this happened to me when i cloned another git to a new one . removing the .git from the cloned folder helped me.

Gantz answered 21/1, 2022 at 16:17 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Frisky
P
0

In my opinion this happens because Github Desktop couldn't add files to staging area automatically, and that's is the reason why you have to do it by yourself.

Using terminal navigate to your project directory (in VS Code you open terminal using CTRL + `. Inside your project directory run git add .After this you can commit using Desktop Github as you usually do or of course you can commit using terminal git commit -m "your commit message".

Petticoat answered 4/4, 2022 at 12:39 Comment(1)
you can commit using git commit via command line as well. It would be good to explain a bit more about why your solution works and what it intend to do.Brigettebrigg

© 2022 - 2024 — McMap. All rights reserved.