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
master
drop-down, selectorigin/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
_config.yml
file. - Edit the
_config.yml
file, making changes to lines 12-19 and save the file. - Right-click the
_config.yml
file and select Commit. -
Right-click the
_config.yml
file in the Changes pane and select Stage.If you haven’t saved the changes you made to the
_config.yml
file you will be prompted to save your changes. - With the ‘_config.yml’ file staged, enter a commit message and click Commit Staged.
- Checkout the
master
branch 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-config
branch in the Merge from branch: drop-down. - Ensure the
master
branch 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.yml
file 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-config
branch into themaster
branch. - 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!