I am working in a PR based workflow and here is the situation created
Two branches were created from master
1. branchA library changes, with its own ongoing PR
2. branchB app depending on library, with its own ongoing PR
Both are two different developers.
branchA
changes some APIs and now branchB
has to adapt to that.
branchB
has to take those changes from branchA
so that they test everything works properly after the API changes
. I am following this approach right now.
from branchB
git fetch
git merge branchA
build your code and check if your changes in branchB
is in sync with API changes from branchA
.
Issue 1 -
Next I push my changes to my PR, but now my PR has files from branchA
as well along with my changes in branchB
. This is happening because branchA
is not yet merged to master
and is still under its own PR review.
To avoid the above issue, I do the following -
I create a local copy of my changes outside the git folder, revert the merge with
git reset --hard
Now I bring those changes from local folder to git and then push it to PR.
Issue 2 -
Now Because of Continuous Integration(CI) jenkins
, both branchA
and branchB
PRs will fail the builds. To avoid this, I disable the app
build on jenkins, so that branchA
PR goes through the CI
. And then I push branchB
with app
build ON.
Question -
one big PR
with all the changes by merging one branch with other (after individual PRs are reviewed
) with internal discussion and then push.You describe a backend/frontend workflow. In my experience the backend is done first, then the frontend. That's the easiest.
Probably you describe a situation with a tight deadline. That way the backender could prepare just an API without actual business logic and provide fake data with a proper format so the frontender could start work sooner. Another solution that the fake API is emulated purely on the frontend but that's more brittle since usually a backender knows better how the API works and what data format exactly.
But if you want your GIT workflow anyway (I'll describe the work for the frontend):
branchB
:git checkout branchA -- src/backend
Where src/backend
- your backend folder
git reset src/backend
(You could use git restore
also)
git add src/frontend
Commit and push into origin/branchB
If you don't need the backend files, clear them:
git clean src/backend