Using git, I understand branching and how to use master, develop, feature branches etc. in day to development for a website after it has gone live.
But for the initial big chunk of development that takes place (12 weeks or so) in order to get the sites first release build I'm not so sure of the best branching strategy.
Is it fine in this stage to commit and push directly on master? If not, what is the preferred strategy for git during the initial development phase before the first release.
preguntado el 05 de mayo de 13 a las 13:05
Is it fine in this stage to commit and push directly on master
In theory, No:
master could only contain stable usable version of your code.
Preferably what is running in production (the live version of your website)
As charles comments below, it depends what you want to do by default when cloning a repo
what is the preferred strategy for git during the initial development phase before the first release.
You can isolate that integration phase on its own branch, which is the result of the merge of one or several rama característica, in order to test all features together.
The first release will see:
- a merge to
- una rama
1.0_hotfixdone from said tag, in order to isolate hot fixes that:
- you will merge to
- you will merge to other feature branches currently developed for
2.0if you think that hotfix makes sense in that new context (some bugs aren't actually relevant in 2.0 because of some 2.0 refactoring)
- you will merge to
Now in practice (and this is where I agree with Charles's https://www.youtube.com/watch?v=xB-eutXNUMXJtA&feature=youtu.be), Si todos the features you are developing will make it to first release, you podría develop everything on
master, release it, put a tag
But once the first release is done, I would still recommend isolate hot fixes in their own branch.
Again, depending on the default role you want
master branch to have, you can develop directly in it.
Try only to avoid merging from master to other branch ("back merge").
If you have feature you have to back port in past release, develop them in their own branch before merging them to
master and to other release branches.
As an example of a large project following that model (development on
master, and branches for release), you can see the organization of gitlabhq.
The idea is to only commit to
master feature that you are seguro will make it to the next release.
Experimental features (that might or might not make it) should be isolated in their own branch (or in
master, pero en un parche de clonado repo, and merged through pull requests).
The only time you should branch (by which I mean create a separate central named shared branch) is where you have some development objective for which you no quiero all of the changes which would normally go into the origin branch off which you are proposing to branch.
It sounds like all of the work you are doing is working towards your one goal - first release. There does not seem to be a good reason to have more than one branch at this stage.
My recommendation is that you actually do the same practice before and after the main go-live. I think that it is not a good idea to have different practices before and after.
I believe that practice should be to never develop in master, always use branches.
Create a branch and when you've finished with the work for a while and you feel it is in a fairly stable, working state, push it to master.
Branches are very cheap, quick and lightweight, look:
checkout -b newbranch I just created one!
Note that this extensive use of branches differs from older version control system where a branch frequently meant you actually wanted to diverage from the main path and go in a different direction.
The one area that I would treat differently perhaps is the 'release' branch which I do agree is a good idea. Before your first release this doesn't exist. After the go-live this will be the branch that is collecting up features/fixes/chores ready for QA and release into master for production.
También puede encontrar https://stackoverflow.com/a/9204499/631619 useful for more git info.
My favorite best practice is the one adviced by git-flow
and the corresponding tool
The way I've always interpreted this, you should do initial development on the
develop branch. From the development branch you do feature branches, and when you are nearing release you do a release branch. You only merge the release branch to
master when you actually do a production release.
Usually, when we talk about git workflows, we assume that we are in a
stable stage. By this, I mean that we are already into a few weeks of development, and adding new stuff or making changes is usual day-to-day life.
But I think that the workflow actually evoluciona with the age of the code.
For example, when you first create a project, you will not bother about creating branches. It does not make sense to think about git that much, when you have not even started coding. This is kind of experimental phase. Everything you write is probably trash.
After a few days of development, your project starts to take shape, and you don't want to break the stable parts of it. And you also want to collaborate with your team members. So you want to create
branches for new features. But quickly
merge a ellos
master too, since the overall codebase is still small, and
Once the code is too big to be manageable, then you actually talk about
git workflows to manage it. And there are many
workflows mentioned all over the place.
So to answer your question, if your codebase is small, focus on making the product right now, rather than managing the code.