Reputation: 1280
I am using git. As of now we are two team members working on a project. Both work is slightly independent as of now, one focusing on UI while the other is focussing on apis. I like to checkin multiple times a day. My typical workflow is:
So I create a feature branch and then work on it, merge it to the main and then push it. Delete the branch and the recreate the same branch.
The product is still the 1st version and we have a continuous integration build server setup. The main purpose of pushing is to get incremental updates to supervisors.
My question is,
Upvotes: 1
Views: 760
Reputation: 7478
Question #1
If I have not finished a feature fully, is it a good practice to push small units of compilable changes to the main server on the main branch if it is still version 1?
No. It is generally not good practice to introduce unfinished code into the main branch. You should always have a branch that mimics the state of production code. For most people that branch is called master
.
One example of why this is important is in the case of bugs in production. If you already introduced a bunch of half-done work into your main branch, then any fixes you release will also include that unfinished work. Also if other developers are pulling from that branch, and you've added untested code, you may complicate their development.
Even if your code has not been released yet - you'll want to have a branch that contains only working and fully tested code. Generally speaking, you should try to break functionality down as much as possible and test small changes. Those can be merged into the main branch if they dont negatively effect anything else that is already working.
However you work, you should try to keep a branch that has some level of "authority" - a branch that is only merged into after meeting some criteria. What that criteria is, is up to you.
You may decide you keep a master branch that the only time its modified is when a new version is being released. You decide instead that you can merge into your main branch as soon as your work as been tested. How you decide to do this is often dependent on the release strategy and the broader workflow.
Question #2
Is it a good practice to create the branch, merge to main, push it, delete the local branch and then recreate it?
Can't answer with a yes/no. There are many strategies for how teams might handle versioning of their code, collaboration between members, and release cycle.
Generally speaking it is good practice to delete branches shortly after they have been merged into the main branch. Its usually better to get rid of and avoid continued use of the same branches (commonly referred to as branches that have a "long life"). Short-lived branches are preferred in most circumstances for individual development tasks - however that may change depending on your teams preferences and choices.
Workflow concerns
You have a small team and your code isnt out in the wild yet - so pressure will be lower and solutions will be easier because its just you two. However, once your product goes into the world pressure will be higher to solve bugs - the the need to release hotfixes/patches will probably arrise. Release cycle will be complicated by more and more simultaneous development. Collaboration will be more confusing and error-prone as you add more and more developers to your team with varying levels of understanding of version control.
So here are a few things I recommend you keep in mind when deciding your workflow.
A popular workflow is known as "git flow", and there is even a command line tool to help automate the steps involved. As a small team you might find it over-complicated - but I would suggest that this is the least you should doing if you have an iteration based release cycle.
I actually am not a huge fan of git-flow, but only because i feel like its actually too simplistic and two-dimensional. (Im not a fan of "decentralized but centralized", I prefer a workflow that is actually distributed).
However if you have a very fast paced release cycle - in which case you might want to adopt the model that github itself uses. Their model is similar to yours, in that they simply merge into master - however they only do so after code as passed some automated tests. The key point to what github does is also the fact that they deploy many times a day - not on a release cycle like most teams do. This makes it so that bugs that make it out to production will almost always be recently introduced. Its a simpler strategy but its not for everyone, keep in mind the bullet points above, especially if you have a more typical release cycle.
Upvotes: 3