Git is a version management tool and I am a big fan of it. I am hoping you came here for git flow. So you have basics of git in your hands. Again on the same note of good practices, I think everyone should work on different branches and then keep merging those branches to the main branch. But that becomes messy cause generally we forget to create a branch. So here is a tool for you.
Note: I am talking about default branches here. You can change that naming convention but I will suggest not to.
So coming back to the topic of git flow.
##Installing on Mac OS X
##Installing on Ubuntu
##Initiating Git flow:
It will prompt you something like this:
Keep pressing enter key to use the defaults. or just do
for accepting all the defaults.
##Whats the whole process:
- First I want to be on a development branch and keep working on the various tasks of the projects.
- For every task of the project we need to create a branch and then merge that branch into develop branch.
- Once code is production ready. We need to create a release and test the code and make appropriate fixes.
- Merge the fixed code into development branch and into production branch.
- Deploy the code and start working on new tasks of the projects.
- Meanwhile there may be a bug on the production server. We need to fix the code via hotfix and then merge the fixed code on the development branch and production branch.
- Now move back on the task we were actually doing before the hotfix. ;)
So now we have git flow ready in our git repository. Let’s do things one by one.
##Create a new feature branch:
For every task we are doing, we will create a feature using git flow. Let’s assume we want to implement login task.
It will create a new branch with feature namespace is feature/login
Now work on this branch and keep committing your code. Now once done. You want to merge it to develop branch. Here is the command for the same.
It will merge feature/login branch to develop branch and delete this feature/login branch.
Keep creating a new feature branch. Keep working on it. Once done, finish that feature and it will be merged on develop branch. Push that develop branch so that other people can pull it.
##Pushing / pulling a feature.
There may be cases when you need to push feature without merging it develop branch do that this by
if you want to pull any feature
##Create a release and push the code to master branch ** ( by default master branch is treated as production branch) **
Now we have code enough coding. We want to finally test the code and then need to push it on production branch. Let’s create a release first so that we can test out the once and make appropriate changes if required.
Now test the code and make any changes that you need to make. Commit those changes. Once done.
This will merge the code into develop branch + master branch and now we can deploy the code from the master branch and then come back to develop branch to implement new tasks.
Now we are working on a new cool task and we are on a feature ie my_awesome_task and meanwhile, we came to know that there is a bug in the production on the title of the page. Now we need to do a hotfix.
Now we will fix that title issue and then commit the code and then finish this hotfix.
This will merge the code into the master branch and into develop branch too. Now you can deploy the code using the master branch and come back to your feature my_awesome_task and do the task. You can check out to your feature branch that you want working on by
I hope this makes some sense. Let me know if you have any doubts or anything.