Actions

EmSys

Git - Resolving Conflicts

From EdWiki

GitLab - Resolving Conflicts

  • Goals
    Learn how to handle conflicts during a merge
  • Merge master to greet
    Now go back to the greet branch and try to merge the new master.
git checkout greet
git merge master

Open src/hello.c and verify the content

The first section is the version on the head of the current branch (greet). The second section is the version on the master branch.

  • Fix the Conflict
    You need to manually resolve the conflict. Modify src/hello.c to be the following.
  • File : src/hello.c
/*
    Author  : J.Shankarappa (jshankar@dese.iisc.ernet.in)
*/
#include <stdio.h>
#include <stdlib.h>
void Greeter(char* grt);
char my_name[80];
int main(int argc, char* argv[]) {
    if( argc > 1 ) {
        puts("What's your name?");
        scanf("%s", my_name);
        Greeter(my_name);
    } else {
        puts("Hello World!!!"); /* prints !!!Hello World!!! */
    }
    return EXIT_SUCCESS;
}
  • Commit the Conflict Resolution
git add src/hello.c
git commit -m "Merged master fixed conflict."