Now that we have our BitBucket account setup, let's create a new repo for our project.
- Click the "Create" button at the top of the BitBucket page
- Name: My Git Website (Name the repository.)
- Description (optional): This is the repo for the "My Git Website" repo on BitBucket by Modules Unraveled.
- [x] This is a private repository (You can uncheck this to make the repository public. If you do select private, you also need to specify forking permissions. A fork is basically when someone makes a distinct copy of your repository that they can make their modifications to without affecting your repo. You can choose to allow forks, allow only private forks, or not allow forks at all. Keep in mind that in order for someone to fork the repo at all, they will need to be granted access to this repo since it is private.)
- Repository type: Git
- Project management: (You can choose to add Issue tracking and Wiki functionality to your repo. I won't cover either in this series, but the functionality is there if you want it.)
- Language: PHP (Select the code language that your project is written in.)
- Repository integrations: (At this point, you can integrate your repo with HipChat. I don't use HipChat, so I'll skip it for now, but if you do, you have that option.)
- Click "Create repository"
Now we're taken to the "Repository setup" page where we're told that the repository is empty. If you watched the GitHub videos, you'll remember that we created the README.md file at the same time that we created the repository. BitBucket doesn't do that, so, we need to create files manually and push them to the repo.
When I expand the "I'm starting from scratch" section and the "I have an existing project" section, you'll notice that they are basically the same thing, the first option just walks you through initializing a repo and adding a file. The basic ideas are the same though:
- Create a repository on your local machine
- Configure the remote repository to be the one on BitBucket
- Push the local repository to BitBucket.
Since they're basically the same instructions, I'll just follow the steps to push an existing project to BitBucket.
Adding an Existing Repository to BitBucket
I'll move into the Drupal directory where I've initialized the git repo and follow their directions
- I'll type "cd /var/www/mygitwebsite" and press Enter
- Then copy and paste the first command from the BitBucket page "git remote add origin email@example.com:ModulesUnraveledScreencast/my-git-website.git" (This sets the BitBucket repo as the central remote. There's no confirmation when this works correctly, but you can confirm that it did by typing "git config --list". If it worked you'll see the line "firstname.lastname@example.org:ModulesUnraveledScreencast/my-git-website.git".)
- Then copy and paste the second command "git push -u origin master" (This pushes the contents of the local repo to BitBucket so that they are in sync.)
- Finally I'll copy and paste the third line "git push -u origin --tags" (My project doesn't have any tags at this point, but it doesn't do any harm to paste the line anyway.)
Now, if we click the "Overview" link in the sidebar, we'll see the contents of the README.txt file, and if we click the "Source" link, we'll see all of the files that make up our Drupal site. So, we're all set!