简体   繁体   中英

Prevent loss of changes when merging parallel git branches

I am following the below strategy for managing my code and deployment:

I have 3 servers qa , staging and prod .

I have 4 main branches: Qa ( which gets deployed on Qa server) Staging ( which gets deployed on staging server) release ( which is replica of master branch) and master branch ( which gets deployed on prod server and is most stable code.

We follow the strategy of working in featured branch for every tickets.

Below is the steps:

  1. Release branch is checkout from master branch.
  2. Now every feature branch is checkout from release branch.
  3. Once the feature is completed its merged to QA branch.
  4. Thats feature is tested on QA server. Once approved its merged to staging branch and tested . Once verifies its merged to release branch.

Now what issue I am facing is that my code is getting overwritten when i am merging from a featured branch to QA branch.

Lets say there 2 developers who has checkout featured branch from release branch.

Now one has made some change in style.css and commited the code in featured branch and files a PR. The code get merged to QA .

Once the same thing is done by other developer some of the code gets deleted.

Please help how to get it resolved so that the code do not gets deleted when the code is merged by some other developer on same file.

On the second merge, git merge would fail with a conflict, in which case your team will have to resolve the merge conflict. That way, no code gets deleted.

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