How to correctly handle this situation using GIT? Is it correct put a v2.0 release on a new branch?



I am not so into GIT and I would like to ask you an opinion about this “work flow” (if it is correct or if I am missing something).

I am working on a software and I have put it on my remote GIT repository (on BitBucket) obtaining a stable version corresponding to the last commit on the master branch.

Then my client has asked me for a pretty heacy change rin this software, I implemented it obtaining a new stable version of my software.

Now I know that I can put it as a new commit on the master branch (and I know that in a second time I can retrieve the old code from it) but I would rather keep the two versions separate (because they basically are different versions of the same application).

So my doubts are:

1) Is it a good idea create a new branch and put this new version on this branch?

2) I created a new branch on bitbucket. What have I to do to put this new version on this branch? I think something like:

git add *
git commit -m "Version 2.0 of my application"
git push origin my-new-branch-name

Is it correct?

3) If this second release of my software will become the official one can I says to GIT something like: “now the new branch is the master branch and the old master is a side branch?


For your questions:

  1. If the software only for one client, it’s not necessary to put changes in a new branch since the released code usually managed in a certain branch. If the software is used for many clients, you should put changes on a new branch in order to meet his/her requirement.
  2. Yes, if the new branch is created on bitbucket, you can switch to the branch locally (git checkout new-branch-name) and use the commands you showed (git add, git commit and git push). The other way is that you can create new branch locally and push it to bitbucket.
  3. Branch names just for you to separate different functions usages. Such as master branch as main branch, develop branch as developers work for a project, feature branch is to develop new features, hotfix branch as fix bugs etc. Different teams can make branch names different, such as the main branch usually can be named main, master, production etc.

Answered By – Marina Liu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More