gitgithubgit-mergedev-to-production

Merging my branch into the test branch and then merging my test branch into the main branch


So basically I am working on my website and I have 2 interns with me.

currently the branch structure is as :

  1. main - the live website code
  2. test - for testing purpose in which all 3 of us merge our branch.
  3. name0(my personal branch) - in this branch I code.
  4. intern-name1 - 1st interns branch
  5. intern-name2 - 2nd interns branch

so I need help with how to merge the branchs for me and my interns

what we are doing curently is as follows:

  1. commit and push into our individual branches
  2. git pull origin test (so that any new changes into the test branches from me or interns can be added into the everyones individual branches).
  3. git checkout test and then git pull origin test
  4. git merge intern-name1

Also I want to from test into main should i merge that by doing git checkout main and then git merge test?


Solution

  • Yes, you can merge test into main. However, having separate development ("test") and production/release ("main") branches is an unnecessary complication for a simple project. Instead have one continuously ready for release main branch and use tags for releases.

    What you're describing resembles the feature branch workflow. However, you're missing the review and test step before merging, and branches should be per feature not per person.

    1. Make a "feature" branch just for this one change. These are per feature (really per issue, feature branch is just the term), not per person.
    2. Update your feature branch periodically from the main branch.
    3. Push your feature branch and have others review it (typically done in a "merge request" or "feature request").
      • Update your branch before pushing.
      • Review includes passing tests.
    4. Once it passes review and tests, merge your feature branch into main.
    5. Delete the feature branch. Make a new one for the next feature.

    When you wish to release, make a tag (such as "prod" or "v1.2.3") and checkout that tag in production.

    There is no need for a separate test branch because each feature branch is brought to go date and tested before merging.

    The review, test, and merge process is complicated and typically managed via a merge or pull request on a development service such as Gitlab or Github.