Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

bitbucket

My colleague created a repository in Bitbucket. I first created a folder in my computer and typed git init. After which,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 reply. It doesn't indicate which branch am i 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 is my mistake? Need some guidance.

like image 222
lakshmen Avatar asked Jun 18 '12 05:06

lakshmen


People also ask

How do I see branches in Bitbucket?

Log in to Bitbucket Cloud. Navigate in your browser to the Source page of a repository. Select Branches on the left sidebar to display a list of branches for the repository.

Why git clone is not working?

If you have a problem cloning a repository, or using it once it has been created, check the following: Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh. This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands.

How do I know if my branch is cloned?

You successfully cloned a Git repository into a specific folder on your server. In this case, you cloned the master branch from your Git remote repository. You can check the current branch cloned by running the “git branch” command.


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 a subdirectory of the empty one.

If you run git branch in the current directory then it will return no branches as the repository is empty and the master branch will be created with the first commit. If you go into the subdirectory then git branch should list the one branch that was created from the remote repository's default branch.

like image 116
CB Bailey Avatar answered Sep 28 '22 12:09

CB Bailey


The Problem

You've essentially created an untracked submodule in your top-level directory. From your description, you initialized an empty directory, and then cloned your BitBucket repository into a subdirectory of your newly-initialized repository.

The Solution

From your current directory, change directories into your current clone.

cd gsadmin
git status

You can move the gsadmin directory around, or re-clone it somewhere else. Either way, the solution is not to clone inside an existing git directory unless you're using submodules.

See Also

Why is "git branch" silent in new repositories?

like image 36
Todd A. Jacobs Avatar answered Sep 28 '22 13:09

Todd A. Jacobs