I've created a bare repository than cloned it. When I do git branch -a nothing is showed. How come I don't even see the default master branch? Although git bash shows the following:
/some/path/project (master)
To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository. To see the remote branches associated with your repository, you need to append the -r flag to the end of the git branch command.
The “no branch” state is called a detached HEAD. It is called this because the HEAD ref is not attached to any branch, instead it is pointing directly at a commit. To attach HEAD to a branch that points to the current HEAD commit, use git checkout -b branchname .
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.
You have probably cloned an empty repository, there is nothing for the master branch to point to.
branch points to a commit
commit points to a tree
tree lists some blobs or other trees
For the repository to show branches, you first need to add the files and commit. Use git add -a for adding all files or use git add <file_name> to add a particular file. After adding the file, use git commit -a to commit all added files. It will take you to the vim editor where you must write the commit message, and exit the editor after saving. Once this is done, you will be able to see the branch master. To confirm type git branch and it will now show you all the branches. Now, you can add other branches by using the command git branch <new_branch_name>.
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