(The code examples below are fabrications to demonstrate the issue with git. Please ignore them otherwise.)
Suppose I have a file source.js:
function maker(str) {
return `Hello ${str}!`;
}
function base(str) {
console.log(maker(str));
}
base("world");
I have branch A with this diff:
diff --git a/source.js b/source.js
index 2eb7de1..6c49051 100644
--- a/source.js
+++ b/source.js
@@ -6,4 +6,9 @@ function base(str) {
console.log(maker(str));
}
+function next(str) {
+ console.log(`${maker(str)}`);
+}
+
base("world");
+next("world");
I also have branch B with this diff:
diff --git a/source.js b/source.js
index 2eb7de1..ecb08f9 100644
--- a/source.js
+++ b/source.js
@@ -1,9 +1,5 @@
-function maker(str) {
- return `Hello ${str}!`;
-}
-
function base(str) {
- console.log(maker(str));
+ console.log(`Hello ${str}!`);
}
base("world");
Both branches are making self-consistent changes. Either can be merge to main, and both can be merged without merge conflicts. However if both are merged, the script no longer runs.
In my specific situation, I cannot merge locally and push to main for security reasons, so it's not possible to merge and test manually.
If I'm using a hosting service (like Github or Gitlab), how do I make sure that merging a set of PRs won't run into this issue?