I am reading about GIT branching strategy that involves master, develop, hotfix, release, feature.
We are 5 developers working on a python website. Following is branching strategy I want to use on GitHub.
- Production code is in the master branch.
- I create a Task branch off the master branch.
- I work on the Task branch, and before pushing the code to git I switch to master and pull the code, switch to Task and merge with master. This is so that my code is in sync with remote master
- Push code
- Raise PR from Task branch into master branch.
What happens if master has got additional code that I am missing in my Task branch and I forget to run step 3?
CodePudding user response:
You won't lose code. If your Task
branch is pushed without being synced to master
first, GitHub will tell you if there are any conflicts.
In case of conflicts, you will get this message on the PR:
Then you can pull master
locally, fix the conflicts and push back the changes to Task
.
If there are no conflicting files, you can merge without updating your Task
branch, even if master
is ahead.
CodePudding user response:
If you're using GitHub, you can add a Branch Protection Rule that requires branches to be up-to-date with the master
branch before they are allowed to be merged in a Pull Request:
The branch must be up to date with the base branch before merging.