The GitHub Extension for Visual Studio editor enables you to identify the difference between the two files and automatically fix the merge conflicts by selecting a specific branch.
While the merge conflict tool found in Visual Studio isn’t specific to having the GitHub Extension installed, the extension allows you to log in quickly (even with two factor authentication), and utilize aspects of GitHub such as pull requests and quickly clone repositories.
To see the GitHub Extension for Visual Studio merge conflict tool in action, perform the following:
If you already completed all of the exercises in this course, you can re-import the course repository and give it a different name.
- Select File > Open > Open from Source Control from the main menu.
- Search for and clone your repository.
- From the branch selection tool in the bottom right corner, select New Branch.
- From the
origin/username-config. Ensure the Checkout branch and Track remote branch options are selected and click the Create Branch button.
- Select the Solutions Explorer tab.
- Open the
- Edit the
_config.ymlfile, making changes to lines 12-19 and save the file.
- Right-click the
_config.ymlfile and select Commit.
_config.ymlfile in the Changes pane and select Stage.
If you haven’t saved the changes you made to the
_config.ymlfile you will be prompted to save your changes.
- With the ‘_config.yml’ file staged, enter a commit message and click Commit Staged.
- Checkout the
masterbranch from the branch selection tool in the bottom right corner.
- Select the Manage Branches option from the branch selection tool in the bottom right corner.
- Right-click the master branch and select the Merge From… option.
- Select the
username-configbranch in the Merge from branch: drop-down.
- Ensure the
masterbranch is selected in the Into current branch: drop-down.
- Click the Merge button.
- When the merge conflict occurs, click the Conflicts: 1 option just below the Merge In Progress text.
- Click on the
_config.ymlfile and select the Diff option. This will display the difference between the two branches.
- Click the Take Source option to merge the changes from the
username-configbranch into the
- Click the Commit Merge button.
- Enter a commit message in the commit message field and click the Commit Staged button.
- Congratulations, you resolved a merge conflict locally with the GitHub Extension for Visual Studio!