Conflicts
User A: Print.java | User B: Print.java |
---|---|
// Driver class
public class Print {
public static void
main(String[] args) {
System.out.println
(Math.add(2, 3));
}
} |
/**
* Application entry point
*/
public class Print {
public static void
main(String[] args) {
System.out.println
(Math.add(2, 3));
}
} |
User A | User B |
---|---|
Edit: ... Driver class ... | - |
git commit, git push | - |
- | edit: ... Application entry point ... |
- | git commit |
- | git push: Fail! |
>git push ... To https://gitlab.mi.hdm-stuttgart.de/goik/gitintro.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://gitlab.mi.hdm-stuttgart.de/goik/gitintro.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again.
>git diff Print.java diff --cc Print.java index fc36ae6,7b27edf..0000000 --- a/Print.java +++ b/Print.java @@@ -1,6 -1,4 +1,10 @@@ ++<<<<<<< HEAD +/** ❶ + * Application entry point + */ ++======= + // Driver class ❷ ++>>>>>>> dbbedb0fc29d77beeaaada37f2538d78f82bac93 public class Print { public static void main(String[] args) { System.out.println (Math.add(2, 3)); } }
<<<<<<< HEAD /** * Application entry point */ ======= // Driver class >>>>>>> 10cf21c ... 759462c public class Print { public static void main(String[] args) { System.out.println (Math.add(2, 3)); } } |
➱ | /** * Driver class, application entry point */ public class Print { public static void main(String[] args) { System.out.println (Math.add(2, 3)); } } |
No. 127
git distributed, DIY
Q: |
Find a partner sitting next to you and repeat the current examples from the section called “Shared development with centralized remote.” and most importantly the section called “Conflicts”. Do not hesitate creating a (source code!) conflict. You'll learn how to resolve it anyway. |