Follow the instructions at bitbucket and install all the necessary things. Then clone the repo:
git clone [link to the repo]
Then you can follow the guideline below and learn about branching and feature deployment. All you need to care about as a feature developer is the dev branch and the feature branches. Don't worry too much about other branches. All you need to do is make a branch from the dev branch and call it
feature-xxxx and then work on it and do whatever you want. Preferably don't remove stuff. Work and make commits and have fun. Also checkout this video that I made that shows how you can use git as a content switcher to look at different features. In summary:
git checkout dev git checkout -b feature-my-new-awesome-feature # you are all set, now get going and do work as much as you want # make commits every now and then by: git add --all git cm -m "some message in present tesnse: eg. adds a cool feature"
If you and someone else work on same files at the same time, conflics will be caused. They are not a big deal because they can be resolved, but make new files with different names if you decided to make another branch from the dev to work on another feature.
Pushing and updatig the remote repo
Once you are ready to share your work with others in the team, push your branch to the remote repo:
git checkout feature-your-branch git push origin feature-your-branch
Pulling and updating the local repo
If you want to update your local repo from the remote, go to any branch that you want and then pull down changes:
git checkout the-branch-you-are-interested git pull origin the-branch-you-are-interested
To see a list of all availabe branches, do:
git branch -a
git workflow example
Lets start a sample project and follow an example workflow!
# initialize a git repo in a folder on the desktop # called someApp cd ~/Desktop git mkdir someApp && cd $_ git init
Lets add a readme file and make the first commit.
touch README.md git add --all git commit -m "adds the readme file"
Now we have the master branch and the first commit. Lets branch off to the dev branch from the master:
git co master git checkout -b dev
Now we are on the dev branch. Remember, nothing is commited directly into dev. Things are added to dev with merges. Now, lets start working on a feature. We call this feature "f1". For this purpose, lets make a branch from dev and work on our feature.
git checkout dev git checkout -b f1 #some work, make new files , etc #…. #…. #lets commit the changes on f1 branch: git add --all git commit -m "adds feature 1 and makes it cool"
Now that the feature "f1" is done we are ready to merge into dev:
git checkout dev git merge f1 --no-ff --no-edit #merge is successful and the f1 branch is ready to be deleted git checkout dev git branch -d f1
Good, we have our first feature implemented! We are ready to deploy. Now, we need to make a deploy-x branch from dev:
git checkout dev git checkout deploy-f1 #here we can make direct commits to deploy-f1 branch until we are happy. #… more wrok on deploy-f1 but no new feature # now we are 100% happy with deploy-f1 and ready to merge to master git add --all git commit -m "adds the deploy-f1 feature and fixes the cahrt"
deploy-f1 is ready, we should mege to master first and then to dev:
git checkout master git merge deploy-f1 --no--ff --no-edit
and then merge deploy-1 into dev:
git checkout dev git merge deploy-f1 --no--ff --no-edit
now that the deploy-f1 branch is merged in both branches, it should be deleted:
git checkout master git tag v.0.1 git branch -d deploy-1
That's it! our feature is deployed and the commit is tagged on the master so we can find it later easily anytime later.
Makeing small fixes on production
When there is an issue that needs be fixed on the production, a new branch from master created called
fix-x. Then once the fix is done, it is merged into master and then merged into dev (the order is not important) and then we finally delete the fix branch.
So, let's say that there is a small bug on v.0.1 and has to be fixed right away:
git checkout master git checkout -b fix-f1
Now, we can fix the issue and commit the fix:
# work on the brnach, add files, etc git add --all git commit -m "fixes a small bug on v0.1"
Now, we merge into master:
git checkout master git merge fix-f1 --no-ff --no-edit
then merge into dev so that the bug fix is added in the next deployment:
git checkout dev git merge fix-f1 --no-ff --no-edit
and finally delete the fix-f1 branch once the merge is successful:
git checkout master git branch -d fix-f1
Branches and Branching
There are main branches and sub branches that are used for developming the application.
The main branches are the master and the dev branch.
The master branch contains the production ready code. Nothing is directly committed to it directly. It gets populated through merges.
The Dev branch contains the main development code. Nothing is directly domitted to it directly. It gets populated through merges.
There are also sub branches that are used. There branches include:
a. Feature-x branches
Feature-x branches, branch off from the develompent branch. Commits are made while on the feature-x branch and then once the feaute is ready, it is finally merged to the dev branch and then the feature-x branch is deleted after the merge is successful.
b. Deploy-x branches
When a feature or multiple features are merged into the dev branch, a deploy-x branch is created from the dev branch. Commits can be made to deploy-x branch (but no new features) and then once ready, the deploy-x branch is meged into the master and then again to the dev branch. And finally, after the mege, the deploy-x branch is deleted.
c. fix-x branches
Used to quickly fix something on the master branch. They branch off from the master branch. After the fix, they are then merged back into master and also to the development or deploy-x branch. And finally, the fix-x branch is deleted after the marges.
To pull the changes run the following. This is equivalent to
git pull origin [name of branch] or git pull #to pull all the changes on the current branch
To push, first add, then commit and the push:
cd [repoRoot] git add . git commit -m "[some message]" git push origin [name of branch]
To push all the branches and changes do:
git push -u origin --all #origin is the name of the remote repo
To merge, first checkout the branch that you want to merge into and then run merge followed by that name of the branch. For instance if you want to merge the
chart branch into the
development branch, do the following:
#before doing anything, make sure to add and commit your changes #before changing branches git checkout development git merge chart