NameHere
NameHere

Reputation: 21

Creating branch form cloned GitHub repository

I have read access to a private GitHub repository. According to the instructions provided i need to clone the repository in my PC using "git clone" and the create a new branch using "git branch" The situation is that when I use the git branch i get the following message:

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

Can someone help me with this situation.

Thank you

Upvotes: 1

Views: 14587

Answers (3)

Kais Ben Daamech
Kais Ben Daamech

Reputation: 122

In order for git to create a branch, the directory you're in need to be a git repository. A directory is a git repository in two cases:

  • It is initialized as a git repository using git init
  • It is a clone of another git repository using git clone "url"

A .git folder is created in both cases containing the git repository structure and files.

Now why did you get the problem? Simply because, even if you have clone the project so you have got a git repository in your local machine, git doesn't recognize it because you aren't inside the folder containing the git repository when you're trying to create a new branch. So you simply need to open a terminal from the inside of the folder containing the git repository, and then do git branch "branch name".

Upvotes: 1

Liviu Pinzaru
Liviu Pinzaru

Reputation: 47

You have to be in the directory that was cloned. If you did that and it still didn't work, try cloning it again, because most likely you deleted the .git file by mistake.

Upvotes: 0

Snaxet
Snaxet

Reputation: 97

after you've cloned it you need to use the command "cd (dir name)". After you've done that then do the branch.

Upvotes: 2

Related Questions