Skip to main content
Tweeted twitter.com/StackSoftEng/status/922937416830341121
edited tags
Link
amon
  • 135.9k
  • 27
  • 295
  • 386
Source Link

How does git/GitHub handle changed local and changed pushed repositories?

I'm working with a few other people on projects, and today I ran into a situation I'm sure I'll see often. One of my co-workers and myself had split up some tasks to do on the same project and began working. He finished his tasks, and pushed his changes to our shared repository. I was still working on my changes, but I was afraid to push them and overwrite the code he had worked on with my project, only containing half the needed changes.

For this situation (just to be safe, I had a presentation on the code in a few minutes and didn't want any major setbacks), I made a copy of my local code, pulled his new code, copied the files I had edited into the project I had just pulled (we were working in two separate sections, but I'm curious as to how git/GitHub handles this issue when working in the same files), and then pushed our combined code. So how does git (or how should we) handle one project with two different changes to the same file?