0

I have created a new repository on github. I followed the instructions there and went to my local machine and at the command line typed

git clone --bare <repoName> <etc>

This creates a new directory (repoName.git) and everything seems to be good. I have one source file I have already (previously) worked on and I want to add it to the repository. I copy and paste the file into the repoName.git directory.

Back at the command line now, I type

cd repoName.git
git add .

This returns:

fatal: Not a git repository (or any of the parent directories): .git

I have seen this message in several online tutorials and some StackOverflow questions, but none of the responses to it seem to be what I need.

My Question: Can someone advise me what I am supposed to do from here forward?

Related:

https://help.github.com/enterprise/2.6/user/articles/creating-a-new-repository/ (Doesn't tell me how to add new files.)

What to do after cloning repo from git This one looks like the OP has a different problem than I have.

fatal: This operation must be run in a work tree The most popular answer tells you what to do but now how. If I knew how to implement one of his suggestions it would probably be the answer to my problem.

Why am I getting the message, "fatal: This operation must be run in a work tree?" If the answer for my situation is in this question, I couldn't figure it out. I tried git config --unset core.bare but it did not help me.

Community
  • 1
  • 1
philologon
  • 2,093
  • 4
  • 19
  • 35

1 Answers1

4

First thing : git add . will not add every file but only the modified and new ones (not those that are deleted). Maybe you should use git add -A.

However this is not your problem : When you use the option --bare, you don't download the working tree, you only download .git directory. See here : https://help.github.com/articles/importing-a-git-repository-using-the-command-line/

If you want to use the working tree just use git clone YOURPATH. Hope it helps !

Community
  • 1
  • 1
PaulDennetiere
  • 179
  • 2
  • 10
  • I will try this now. Back in a moment. – philologon Jun 01 '16 at 14:11
  • This works. This page tells me to use --bare, so that is what I was going by. I have no idea why they tell you that. https://help.github.com/enterprise/2.6/user/articles/importing-a-git-repository-using-the-command-line/ – philologon Jun 01 '16 at 14:18
  • 1
    That docs describe how you copy a Git repo from `githost.org` (wherever that may be) to `github.com`. So you clone and immediately push the repo, no need for local files. – Nils Werner Jun 01 '16 at 14:20
  • 1
    In fact many Github repo are used daily by developers : They often represent some tools that may be useful for a lot of person. Those developers will use this bare option to have a complete repository (therefore a working technology), but will not collaborate on the development of this repository itself (and so don't need the working tree). – PaulDennetiere Jun 01 '16 at 14:23