Humba
Humba

Reputation: 128

How to create project versions

I have a project that I'm using git to control its versions. Now, I'm going to work on a 2.0 version that will be uploaded to the server after we finish it. So, I decided to create a new branch to develop the 2.0 version.

My question is: as the master branch is always having bugs fixed, I need to upload this changes to the server without upload the changes related to the version 2.0.

How do you do to make it? The best solution I could find is use git archive to extract the master branch without the changes made on the branch version 2.0. This is really the best solution?

Upvotes: 1

Views: 65

Answers (2)

Sergey P. aka azure
Sergey P. aka azure

Reputation: 4732

Think of your master branch as of code for production. There you fix bugs. And think of your master_2_0 branch as of branch that will be on production some day. There you develop new cool features.

Now when you did some development in master_2_0 and fixed some critical issue in master you should make a merge. Make sure before merge that you have your local branches master and master_2_0 in actual state

git checkout master_2_0 #switch to master_2_0 branch
git merge master # merge branch `master` into master_2_0

This is how fixes from master will go to master_2_0. Sometimes merge conflict may appear if you changes the same parts of the code. You should carefully resolve them.

So doing merge will leave your master branch as it is while will keep master_2_0 branch updated with the fixes from master.

You should deploy to production only the master branch. It depends on how do you deploy. Usually it's done using git clone with specifying branch that you want to checkout (master by default).

git archive also will work for you, it also allows to specify branch that you want to be archived.

Upvotes: 1

smarber
smarber

Reputation: 5074

AFAIU the branch master is the only branch which needs to go live. So everytime a new bugfix is added to the branch master, you need to rebase it into your new branch. This way, you new branch contains already the fixes.

And finally you can upload the changes of master by using git archive to avoid sending your .git as well.

Upvotes: 1

Related Questions