0

Currently, I'm working on a PHP project with three team members on GH. We split up tasks, but came to the conclusion that when contributor1 codes one screen and styles it in our CSS file, this will all be lost when contributor2 would push their own CSS file onto our main branch.

Does anyone know a good workflow on how to prevent this from happening?

Our current workflow:

  1. C1 has created a project and added C2 & C3 as contributors.
  2. C2 and C3 forked the project
  3. Everyone cloned it into their VS Code and created a local side branch.
  4. After done working, we commit and merge to our own main branch.
  5. We create pull requests to the main project (repository from C1 where everything should be connected).
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Rix11
  • 23
  • 4

1 Answers1

0

If C2 and C3 fork the project, they should add an additional remote to their local clone:

git remote add upstream /url/original/project

Then, before each pull request to the main project

cd /path/to/local/clone
git switch pr_branch
# work
git fetch upstream
git rebase upstream/main <= replay pr_branch commits on top of the original main branch
git push --force

The idea is to make sure the local code still work with (and take into account) the latest commits from the original repository.

Each git push --force will update the PR in progress.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • why is the use of force required? resp. why do you recommend a rebase+force over a merge that comes with less risk of breaking things because it does not need force? – lucidbrot Mar 21 '22 at 08:04
  • @lucidbrot It is a pull request branch where, most likely, only one developer is in charge: it will be fine. – VonC Mar 21 '22 at 08:08
  • Thanks a lot already! I will communicate this back to the team and try this out! – Rix11 Mar 21 '22 at 08:42