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.
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.
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.
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.
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.
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.
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.
Why is "git branch" silent in new repositories?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With