user17772885
user17772885

Reputation:

git status "fatal: not a git repository (or any of the parent directories): .git"

I am collaborating with my teammates on a Project in which one of my teammate has uploaded our project on GitHub.

I want to clone the repository into my VS Code.

Here are the steps I have performed:

  1. I clicked the "Fork" button on the top right corner of my teammate's repository.
  2. Then I go to "Your Repositories" and clicked the repository in which I have forked just now.
  3. Then I clicked the Green Button "Code" and copied the URL of my repository.
  4. Next, I go to my VS Code and typed git clone <URL> in which the URL is the URL that I have just copied.
  5. Then my VS Code Terminal shows this long message:

Screenshot 1

  1. Then when I run git status, the output is fatal: not a git repository (or any of the parent directories): .git as you can see at the bottom of the screenshot.

May I know did I do any mistakes? What are the correct steps to rectify the issues displayed by the Terminal? Thank you.

Upvotes: 4

Views: 18779

Answers (3)

Vasuki Venkat
Vasuki Venkat

Reputation: 1

Just check are you in correct directory where you have cloned project. Then run below command to pull code

git pull -r

if this is not working check in your current directory has .git file. If it's not there it's not a git directory you have check and clone again.

And also try go into next directory from current directory and run the same command.

git pull -r

It may be a git directory but you tried out side of that parent directory.

Upvotes: 0

VonC
VonC

Reputation: 1324228

I have tried running cd student-course-registration-system and when I run git status again, my Terminal shows this result:

https://ibb.co/VDTQj2N

As mentioned in the screenshot, use git restore:

git restore --staged --worktree -- .

That will restore all files from HEAd commit to your working tree and index.

Upvotes: 0

Surya Teja Pasumarty
Surya Teja Pasumarty

Reputation: 21

You need to be present in the active directory in which the git repository was cloned.

cd into the downloaded directory then VS Code will automatically get updated with the current repo.

Try using extensions like Git lens and other git-related extensions that make this process easier.

Upvotes: 2

Related Questions