Fatal: Not a git Repository

Asked

Viewed 41,436 times

14

I created a la repository on Github and then went to play files through Git using

cd C:\Users\Nikolai\Desktop\exercicios-c
git remote add origin https://github.com/NikolaiCinotti/exercicios-c.git 
git push -u origin master

And I got the mistake:

fatal: Not a git Repository (or any of the Parent Directories): . git

I’ve already created a repository that in this case is this: https://github.com/NikolaiCinotti/exercicios-c

  • Make sure you’re in the right project folder when you try to open the branch.

1 answer

23


Your repository is empty. You must first initialize it on your local machine, and only then can you do it push. The procedures are as follows::

Creation of local repository:

> cd C:\Users\Nikolai\Desktop\exercicios-c
> git init

Then add any file, it can be source code, text, image. Anyone. It is normal to have a "Contributors.txt" file in the repository, with the names of the development members.

> echo "Nikolai Cinotti" > contributors.txt

Add the file to the repository and commit:

> git add contributors.txt
> git commit -m "Primeiro commit!"

Send to remote server:

> git remote add origin https://github.com/NikolaiCinotti/exercicios-c.git
> git push -u origin master

By using Windows, the syntax of the commands may have some changes that I do not know because the Windows terminal is more limited than Bash.

Correction: had typed the command git push wrong. Note that the second parameter is -u, and not -i as I had typed.

  • Thanks for the explanation! I was a little lost because the course I’m doing didn’t do Git init. Maybe it’s because the course is from 2012. It’s one of the Cape/Bay. Thanks!

  • <Why is it necessary to use -u or -i ? What is the difference between the two? And what happens if I don’t use any?

  • The -i was a typo hehehe.... o -u is to mark the remote origin as standard remote (short for --set-upstream). So the next time you want to send commits to the server, just write git push =]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.