Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix: error: '<filename>' does not have a commit checked out fatal: adding files failed when inputting "git add ." in command prompt

I'm trying to add a ruby rails file to my repository in gitlab but it somehow wouldn't allow me to add the file saying that my file does not have commit checked out.

I've tried git pull, making the the file again and git adding but still wont work

error: '172069/08_lab_routes_controllers_views_172069_172188-Copy/adventure_game/' does not have a commit checked out fatal: adding files failed 
like image 934
mark29230 Avatar asked Jul 03 '19 15:07

mark29230


People also ask

How do you fix does not have a commit checked out?

you will see this message. This can happen if you have a git repo and then create/clone another repo in a subdirectory under that repo. In my case, I accidentally created a directory name ., inside the repository. Removing it solved the issue.

Why does git say fatal add files failed?

The folder which is giving you fatal: adding files failed message on git add command is actually implying that there is another . git folder inside the folder. If you navigate to the particular folder address, you can remove the file and put git add. It should work.

How do you git add all?

To add and commit files to a Git repositoryEnter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.


1 Answers

If you have a subdirectory with a .git directory and try to git add . you will see this message.

This can happen if you have a git repo and then create/clone another repo in a subdirectory under that repo.

like image 119
Mario Zigliotto Avatar answered Sep 21 '22 10:09

Mario Zigliotto