For a team project, we are using Git and Bitbucket to manage our repository.
Somebody else has started a new project in a new repository. This repository can be seen on BitBucket, with a single master branch.
I want to download this repository to my own computer. I want to work on the project in my own branch, periodically saving the branch back to the repository for safety. When I’m finished, I want to merge my branch back with the master branch.
How do I do this?
Here is my cheatsheet for creating a new branch from the master branch on an existing project, working on it, then pushing my branch back to the repository.
In Windows Explorer, create or open a folder to hold your various Git projects. In it, right-click and Git Bash Here.
Clone from the server to your computer:
git clone https://bitbucket.org/your-teamname/project-name
This will create a new folder on your computer with the repository files inside.
Change directory to go inside the newly created project folder:
Create a branch:
git branch JR-branch
Use checkout to switch to a branch:
git checkout JR-branch
Add any new files:
git add *
Commit any changes. Note that nothing is uploaded yet!
git commit -m "comment"
Upload (“push“) your changes to the repository:
git push origin JR-branch
You should now see your branch on your Bitbucket project.
The ‘no deep shit’ guide to Git – highly recommended