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

帅比萌擦擦* 提交于 2020-04-12 18:04:16

问题


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


回答1:


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.




回答2:


I had the same error Message. I fixed it by deleting the file which causes the error from my Directory.

I hope this helps =)




回答3:


You don't need to delete the entire file from the directory as the first answer suggests, I just had to delete the .git directory, and then your git add . will work

This happens for the reason @Mario Zigliotto suggested, there is another repo in a subdirectory under that repo.




回答4:


I had the same error message when trying to add multiple files using "git add ." I was able to add all those files one by one instead of all at the same time.



来源:https://stackoverflow.com/questions/56873278/how-to-fix-error-filename-does-not-have-a-commit-checked-out-fatal-adding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!