Post date: Apr 25, 2016 8:38:25 AM
Source Tree Installation
Install SourceTree using this link: https://www.sourcetreeapp.com
During the installation process, you will be asked to login to your Atlassian account. This is your Bitbucket account which you should already have. If not, ask one of the ADXBA Bitbucket administrators to create one for you.
Once installed, go to Tools > Options and make sure Do not fast forward when merging, always create commit is ticked. This forces a new commit to be created when merging branches.
Download KDiff3 using this link: https://sourceforge.net/projects/kdiff3/files/latest/download?source=files. This will be used to resolve any conflicts when pulling/pushing changes
Go to Tools > Options > Diff and select KDiff3 for ‘External Diff Tool’ and ‘Merge Tool’
Starting a New Repository
Getting the Repository Setup
Go to https://bitbucket.org and click Create Repository page under the Repositories dropdown.
You will greeted with the Create a new repository page. Make sure the owner is set to ‘ADXBA’ and NOT yourself. Otherwise, other ADXBA users will not be able to see or clone it.
Select an appropriate project. If a suitable project does not exist, ask an admin to create one.
Give the repository a suitable name. Use spaces and not underscores & use capital letters.
Make sure ‘This is a private repository’ is ticked.
When you’re happy, click Create Repository.
Cloning the Repository
Open Source Tree and click Clone/New in the top left.
Click on the globe on the right of the Source Path / URL and find the repository you created with Bitbucket in the list.
Select a suitable destination to have the repository cloned to.
e.g. C:/Kieran/Bitbucket/[folder name]
Click Clone.
Once the repository is cloned and available to you in SourceTree, do an initial commit. and you are currently on that repository, you will need to click Git Flow in the top bar. This will initialise the repository with develop, master, hotfix etc. branches. Read more on this below.
The following process is similar to cloning a new repository except the final step which requires a little extra work.
Click Clone/New in the top left of SourceTree.
Click on the globe on the right of the Source Path / URL and find the repository you created with Bitbucket in the list.
Select a suitable destination to have the repository cloned to.
e.g. C:/Kieran/Bitbucket/[folder name]
Click Clone.
Once the repository is cloned, it is likely that only the master or develop branch is missing from the branches on the left. Go to Remotes > origin > right click the branch that is missing and click Checkout origin/[missing branch].
When developing, make sure you are in the develop/feature/hotfix branch. You should never make code changes whilst in the master/release branch.
Changes destined for the next release are placed here. This can be by directly committing small changes or merging other branches (e.g. feature branches) into this branch.
This represents the latest released / deployed codebase. Only updated by merging other branches into it.
If you start work on anything non-trivial, create a feature branch. When finished, merge this branch back into the development branch.
When you’re about to package a new release, create a release branch from the development branch. You can commit to it during preparation for a release and when it’s ready to be deployed, merge it into both the development branch and the master branch (to indicated that the release has been deployed).
If you need to patch the latest release without picking up new features from the development branch, you can create a hotfix branch from the latest deployed code in master. Once you’ve made your changes, the hotfix branch is then merged back into both the master branch (to update the released version) and the development branch (to make sure the fixes go into the next release too).
Read more on smart branching: http://blog.sourcetreeapp.com/2012/08/01/smart-branching-with-sourcetree-and-git-flow/
Committing
You should NEVER make any commits in the master branch. The code in the master branch should only be updated by merges from other branches.
Committing in the develop branch is the simplest commit. Simply make sure you are in the develop branch, click commit. Stage the files you wish to commit and make an appropriate comment.
You can tick Push changes immediately to origin/develop if you wish to have the remote branch updated.
If you wish to start a new Feature/Release/Hotfix branch, press SHIFT + ALT + F.
Choose the type of branch you would like to start.
Give the branch an appropriate name.
Features and hotfix branches should use lowercase letters with dashes instead of spaces.
Releases should be named either using v0.0 or v0.0.0 format.
Once created, you can make commits to that branch. Make sure you have the branch you wish to commit to selected, click commit and follow the same process as committing on the develop branch above.
When you need to finish the branch, press SHIFT + ALT + F again. And click ‘Finish [branch]’. Source Tree will automatically do any merges to other branches that are needed. e.g. When finishing a feature branch, it will be merged into the develop branch.