-1

I am extremely new to git.

I am using Git CMD.

When I type git clone .... I am able to clone the repository successfully, but when I type git branch -a, it doesn't give me a list of all branches available.

What am I doing wrong?

My end goal is to use git cmd to switch branches.

This is what happens:

c:\users\username\projects>git branch -a

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

  • 1
    Even though you've done a clone .. Have you done a full git fetch remote? Can you check out the branch that's "not there" ? – Zak Aug 10 '22 at 15:29
  • 3
    It looks to me that you're not in the project directory .. Like you should be in `c:\users\username\projects\my-project` – Zak Aug 10 '22 at 15:30
  • I'm going to need to see what git fetch does. One sec. – Chicken Sandwich No Pickles Aug 10 '22 at 15:42
  • When I moved to the name of my project and typed git branch -a, it gave me a list of all of my branches. That's the solution to my problem. Thank you for helping a n00b out. – Chicken Sandwich No Pickles Aug 10 '22 at 15:43
  • 1
    Yup. Git clone doesn't (can't) switch your shell into the cloned directory, it's one of those way-too-susceptible-to-abuse features that's just never going to happen. cd in after cloning. – jthill Aug 10 '22 at 15:44
  • As written, I think your question is misleading when you say "not showing **all** branches", and also "it doesn't give me a list of **all** branches available". It's not showing **any** branches because you weren't inside of a repo. – TTT Aug 10 '22 at 18:55
  • I think if you had asked your question based on the error message, then it would be a dup... Does this answer your question? [fatal: Not a git repository (or any of the parent directories): .git](https://stackoverflow.com/questions/20413459/fatal-not-a-git-repository-or-any-of-the-parent-directories-git) – TTT Aug 10 '22 at 18:57

1 Answers1

1

Git is installed on a "per project" basis. So each project will have it's OWN GIT repository. You need to be sure you are in the project directory you want to be in, and then issue your git commands IE:

c:\> cd c:\users\username\projects
c:\users\username\projects> cd my-project
c:\users\username\projects\my-project> git branch -a
Zak
  • 6,976
  • 2
  • 26
  • 48