0

I am learning how to use git. I am unable to add all the files once but individually can.


Error : doesn't have a commit checked out.

Its been long i have been trying to use git, have followed 3 videos. In the videos, they successfully able to do all the operations but I receive an error which they don't. I am not able to setup the git. I have attached the screen shot for your reference.

Also, please refer me to some tutorials or book in which i can get right from git installation. I am using Windows 10 and git version 2.27.0.windows.1

If somebody can, list down all the steps, so that i can follow it and if error occurs and can point out specific step and error. As there are many ways to setup git, i have to follow where i have incomplete project, which i can push and can restart working on code.

Early help would be much appreciated.

Thanks Error Image

gs1208
  • 73
  • 5
  • 9
  • 1
    It looks like the pro1 subdirectory is registered as a submodule. Do you have a `.gitmodules` file at the root of your repo? – LeGEC Jul 11 '20 at 09:43

2 Answers2

1

It seem like you have another git repository(nested git repositories) initialized in the "pro1" directory. I don't think you require that. Remove ".git" from the "pro1" directory. You can use command on git bash(command line of which you have posted the screenshot):

rm -rf pro1/.git

Now use following command to add all the files:

git add .

or

git add -A

Another alternative is that you first commit and push the code in "pro1" directory and then try to push the code outside that directory. But that is not the recommended way of handling the git repositories.

You can refer Traversy Media tutorial for quick reference. It will work for most of cases. if still you face issue, just copy and paste that error on google, you will get the right answer.

YATIN GUPTA
  • 916
  • 9
  • 17
  • I don't have nested git repositories. In the express folder, I have created different folders and in that folders i have created projects. There is no other .git folder. I tried both git add . or git add -A , you can see the screenshot. But same error persists.I have watched Traversy Media tutorial and followed it, but i am getting error, where he wasn't – gs1208 Jul 11 '20 at 04:49
  • Can you ping me "git status" and "ls -la" output from inside the "pro1" directory? – YATIN GUPTA Jul 11 '20 at 05:07
  • Thanks for your extended effort. Here are the response from running these command. I would have put photo, but i don't think in the comment we can do that. The response is too long for the comment. How do i send you the response? – gs1208 Jul 11 '20 at 08:06
  • Yes, you were right. I do have Another directory pro1 and in it have another .git folder. Thanks, my mistake i did not look that carefully. – gs1208 Jul 11 '20 at 11:17
0

It looks like the pro1 subdirectory inside your repo is registered as a submodule.

To confirm this : run cat . gitmodules from your repo base directory.


If this was unintented, follow this procedure to remove it :

git submodule deinit pro1
git rm pro1
rm -rf .git/modules/pro1

If you want to have pro1 as a submodule within itself : go into pro1, and choose what should be checked out there :

cd pro1
git checkout some/branch
LeGEC
  • 46,477
  • 5
  • 57
  • 104