Basic question about 'merge' - I think #21589
-
I want to ask this so I don’t go along with the wrong basic assumption. I believe I understand version control, I used one in a previous job to do backups of network device configurations (it was cheaper than Solarwinds 😁). Obviously that didn’t need branches, I just needed copies of what it looked like as of ‘x’ time. But I have never used one for code. And I get the idea of multiple people working on an application, and wanting to merge their work into the ‘mainline’, etc. Here’s the basic question: Am I correct that git has no knowledge of ‘code’ and while it may have capabilities like ‘diff’ - detecting what lines are different - it is the responsibility of the users to make changes that will work together? Here’s an example: Repo ‘myprogram’ contains a function ‘function1(arg1)’. I am working on the mainline, and my co-developer creates a branch to work on an added feature. That branch changes function1, let’s say it adds an argument arg2 (I’m learning Python so…). My work in the mainline uses function1 with just arg1. If the branch is merged with the mainline, the mainline breaks because, absent any other actions, my calls to function1 only have a singe argument? I appreciate your help! Paul |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
That’s correct. That is why you would also want to be making your changes in your own branch. Here is the scenario: You are working in your branch. |
Beta Was this translation helpful? Give feedback.
-
Thank you, and that sounds like a good suggestion. I appreciate it. Paul |
Beta Was this translation helpful? Give feedback.
That’s correct. That is why you would also want to be making your changes in your own branch. Here is the scenario:
You are working in your branch.
Your coworker is working in their branch.
Your coworker merges their code to the main branch. At this point, you are out of sync with the main branch.
You “should” do a pull, to pull in the changes from the main branch to your branch. That will cause a conflict for you that you can resolve on your branch.
When ready, you can then push back to the main branch. You may still get a conflict if you change your workers file in your branch, which then you can fix before merging to the main branch.