Why doesn't my git branch display anything in my new BitBucket clone?

My colleague created a repository on Bitbucket. First I created a folder on my computer and typed git init . After that, I made a clone from the repository to my computer using the command: git clone address .

But when I type git branch , there is no answer. It does not indicate which branch am I'm in.

 git init Initialized empty Git repository in /Users/IMAC/GsAdmin/.git/ git clone address Cloning into 'gsadmin'... Password: remote: Counting objects: 32, done. remote: Compressing objects: 100% (24/24), done. remote: Total 32 (delta 3), reused 0 (delta 0) git branch git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .DS_Store # gsadmin/ nothing added to commit but untracked files present (use "git add" to track) 

What's my mistake? It is necessary to be guided.

+6
source share
2 answers

There are two ways to create a git repository. You can use git init to create a new one, or you can use git clone to clone an existing one. If you run both init and clone , then git will first create a new empty repository in the current directory and then clone the remote repository into an empty subdirectory.

If you run git branch in the current directory, it will not return any branches, since the repository is empty, and the main branch will be created with the first commit. If you go to a subdirectory, then git branch should specify one branch created from the default branch of the remote repository.

+15
source

Problem

You have created a substantially unrestored submodule in your top-level directory. From your description, you initialized an empty directory and then cloned the BitBucket repository into a subdirectory of your newly initialized repository.

Decision

From the current directory, change directories to the current clone.

 cd gsadmin git status 

You can move the gsadmin directory or re-clone it elsewhere. In any case, the solution is not to clone inside the existing git directory unless you use submodules .

see also

Why is there a git silent branch in new repositories?

+1
source

Source: https://habr.com/ru/post/918322/


All Articles