简体   繁体   中英

git syncing up branches after a multiple of hotfixes and a feature commit

Hi: I have 2 branches master and dev which were in sync about 2 weeks ago. Would like some help on how to move a feature (commit F) to master branch now. Have been reading up a number of git workflow models, just need to make sure I have understood it right before I commit and push the changes.

2 weeks ago master

...-C-D-E

acpt

...-C-D-E

I added two hotfixes (H1 and H2) on two different dates, while working on another feature (commit: F) at the same time. So the branches look like this master

           H2
          /
         H1
        /
...-C-D-E

dev

         H1 H2
        /  /
...-C-D-E-F

My questions are the following
1. Now I want to move F to master. I was going to do git merge dev while in the master branch. Is there anything wrong with this
2. Or should I be doing git merge <commit-id for F> while in the master branch.
3. Or should I be developing F in a new branch and merging that branch into master and dev

As far as I understood from your development workflow, you are working with gitflow workflow. In this workflow the main branches are:

  • master - the most stable main branch
  • development - development branch to develop and merge features in there (initially created from master)
  • feature branches - each time you want to develop a new feature, you have to create a new feature branch from latest development
  • hotfix - for hotfixes on master (if release is broken)
  • release - created from development to push (release) changes to master

If you were working on development instead of feature branches, then you have to merge development to master first and then follow the workflow. To answer your question: better to use first option:

git checkout master
git merge dev //to merge dev into master

And then push to remote master.

To make github happy (if you use github), you have to merge master back to development (so it would not diverge and will not complain).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM