5

I'm new to git. I'm using bitbucket with sourcetree client. I've cloned the repository from bitbucket in the sourcetree ,and then I wanted to create a Develop branch from Master. The thing is : there isn't any master branch. I've tried committing some text file , and then I was able to create that Develop branch , but I still don't see master branch in BitBucket ,so I can't create pull requests from the Develop branch to master...

What have I done wrong? Thanks

BVtp
  • 2,090
  • 2
  • 21
  • 50
  • 1
    Please paste the output of `git branch -vva` to your question. – ckruczek Jun 10 '15 at 06:56
  • Is it a brand new empty repo created on BitBucket? Because a new Git repo has no branch initially (as I pointed out in http://stackoverflow.com/a/17096880/6309) – VonC Jun 10 '15 at 07:00
  • Yes, I have a remote repository(if I'm correct) opened in bitbucket , a folder of the tasks I need to submit (through Jira). Now I had to create a branch from the master branch , and then create a pull request between them so that my tasks can be examined. – BVtp Jun 10 '15 at 07:07
  • @ckruczek Here's the output : * Development_v0.1 17f7dbb no message | master 17f7dbb [origin/master: gone] no message | remotes/origin/Development_v0.1 b647f22 no message – BVtp Jun 10 '15 at 07:31
  • Please format your code better next time. But for me it looks like you do have a `master` branch – ckruczek Jun 10 '15 at 07:39
  • why can't I see it in BitBucket under Branches section? I can only create branches from the Development branch.. – BVtp Jun 10 '15 at 07:41
  • Well it looks like you really just have the master branch on local and not on remote. Was the repository a brand new one, than most of the repos do not have any branch. That would explain the situation. – ckruczek Jun 10 '15 at 07:49
  • But doesn't master branch should be local in fact? I mean , every repository has its own master branch ? or a master branch is a remote branch which is mutual to all the local repositories cloned from it? most importantly - how do I create a pull request between master and Development ? I see only Development branch in bitbucket.. – BVtp Jun 10 '15 at 07:57
  • If you create a initial repository there is no branch at all. You to create it with the first commit. On your local machine you do have a master as I can see from your output and it points to the commit `17f7dbb` But obviously you haven't pushed this one. – ckruczek Jun 10 '15 at 08:00
  • So does it work that way : Original/head is like a remote master branch. Then I have my local master branch . and from it I create another branches like Development ? – BVtp Jun 10 '15 at 08:15

5 Answers5

5

master is just a name for the usual default branch. But it doesn’t need to be called that way. If you do git branch -r you can see what branches exist on your remote, so you know which branch you could create a pull request for.

If you really want a master branch, you could just create a new branch.

poke
  • 307,619
  • 61
  • 472
  • 533
  • Thank you. I'm using sourceTree client. Is there an option for command lines there? – BVtp Jun 10 '15 at 06:58
  • You can tick the “show remote branches” option at the top to see remote branches in your history. – poke Jun 10 '15 at 07:01
  • I've got two lines (btw, I'm using Mac if it's important) : 1. (at the description: ) "master" , and then "develop" no message. 2. (at the description: ) "origin/develop" no message. – BVtp Jun 10 '15 at 07:04
  • So there seems to be only a develop branch on the remote then; then provide a pull request for that branch. – poke Jun 10 '15 at 07:05
  • * Development_v0.1 17f7dbb no message | master 17f7dbb [origin/master: gone] no message | remotes/origin/Development_v0.1 b647f22 no message – BVtp Jun 10 '15 at 07:26
2

If you will try to clone the empty repository, while cloning you should be getting the following message in command line prompt.

Cloning into 'test'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

So, it means you are starting a project from scratch. In this case you have to follow the following steps -

mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin "Your Repo Url"
git add -A
git commit -m 'Your Commit Message'
git push -u origin master

Same streps are also mentioned in bitbucket home page of your repository. It will create your master branch.

Abhishek
  • 2,443
  • 3
  • 25
  • 42
1

You have to initialize your repository with your username and name, after that your master branch will be created and you will be able to commit your code.

git config --global user.email "your@email.com"
git config --global user.name "Your Name"
0

In Bitbucket, commit the default README.md file that Bitbucket offers to generate. The master branch will be created upon committing the README.md file.

Stephen Rauch
  • 40,722
  • 30
  • 82
  • 105
paulyb
  • 202
  • 3
  • 8
-1

In BitBucket,

Click on Commits, and commit any file (A sample readme and .gitignore file). It will be automatically commited to the master branch.

And then you will be able to see the master branch and can create new branches also.