A
A
anton_kP2022-02-09 18:50:49
GitHub
anton_kP, 2022-02-09 18:50:49

Is it possible in github to merge code in one file when working together, and not replace versions?

Tell me about three questions, I can't figure it out:
1. Let's say two programmers download updates to themselves in the morning, work on one file and, as I read, they can upload their versions to the project. When you work alone, everything is simple, but let's say in a team it is not clear how edits will be saved and merged.
For example, I changed the file a lot, threw out some of the code, added some, made changes somewhere. I uploaded it to the project, and my colleague, a little later, also uploads his improvements to the project. It turns out that he will replace my file with his own. Is it possible to make the code of our files be merged and not replaced.
For example: I am developing html layout and working on the header, and a colleague is working on the footer. And we shouldn't overwrite each other's edits.

2. Do I understand correctly that in order to work on my computer and upload changes, I must install git on the server where the site is running in order to see the files on my computer? I don’t quite understand how to set up folder synchronization with the site via github.

3. Is it normal to create a sandbox-type repository in github and store different pieces of code there (layout templates, css examples) or github is needed specifically for project management. Previously, he kept all sorts of things in services, such as Codepen.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2022-02-09
@anton_kP

It turns out that he will replace my file with his own
It will not replace, because when he tries to submit his edits, he will receive a message that there are conflicts that need to be manually resolved.
But since resolving conflicts is another rigmarole, the developers agree in advance what and where they are doing so that the work areas do not overlap as much as possible, and the files are made small (for example, the header and footer are placed in their own separate templates).
Do I understand correctly
The git on the server has nothing to do with your computer.
Is it normal
Yes, do what you want, the Gita police have cut funding and they are not arresting anyone now. But in general for "pieces of code" there is https://gist.github.com .

S
Saboteur, 2022-02-09
@saboteur_kiev

Files that have changed in different places will automatically merge the changes.
If you corrected the same line, the one who will submit his changes last will receive a notification, receive a file with all the changes and he will need to resolve the conflict by hand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question