|
| 1 | +## Welcome to Challenge 15 |
| 2 | + |
| 3 | +Congratulations on successfully completing the 14th challenge! This marks the completion of the second milestone of the challenge. |
| 4 | + |
| 5 | +Before you proceed with the 15th challenge, ensure you are required to have completed the following tasks to successfully mark the completion of the 2nd milestone: |
| 6 | + |
| 7 | +## Preqrequisites to mark completion of 2nd Checkpoint (Milestone): |
| 8 | + |
| 9 | +1. Use the creative shared for the successful completion of the second milestone: [Second Milestone Creative](https://github-production-user-asset-6210df.s3.amazonaws.com/129844674/268165917-34df9c63-be61-4ffc-af43-264703f89f0a.jpg) to share on any social platform: LinkedIn, Twitter, Facebook, Instagram, etc. marking the completion of the second milestone. |
| 10 | + |
| 11 | +2. Fill the Google form the following Google form: [Google Form](https://forms.gle/JnzBURSEjRejEgw4A) to mark the completion of the second milestone. Note: This is a mandatory task to be eligible for the prize at the end of the challenge as it allows us to evaluate the submissions in the challenge so far. |
| 12 | + |
| 13 | + |
| 14 | +Once you have completed the above, you can proceed with the 15th challenge. |
| 15 | + |
| 16 | + |
| 17 | +## Task: |
| 18 | +Welcome to the 15th challenge! |
| 19 | + |
| 20 | +Read this [article on merge conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) as it is very important. |
| 21 | + |
| 22 | +Today is the first part of a two-part challenge related to resolving merge conflicts. To get started, follow these steps: |
| 23 | + |
| 24 | +Task: |
| 25 | +Create a Scenario for Merge Conflict: |
| 26 | + |
| 27 | +- Create a new project on your local system (e.g., a code project or a text file). |
| 28 | + |
| 29 | +- Intentionally make changes to the same lines of code or content in different branches of your project to create a scenario where a merge conflict would occur during a merge or pull request. |
| 30 | +Resolve the Merge Conflict: |
| 31 | + |
| 32 | +- Follow the steps outlined in this [article](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) to understand how to resolve merge conflicts. |
| 33 | + |
| 34 | +- Use the techniques mentioned in the article to resolve the conflict you intentionally created in your project. |
| 35 | + |
| 36 | +- Share Screenshot: Take a screenshot of your terminal or Git client when you are resolving the merge conflict. |
| 37 | + |
| 38 | +- Share this screenshot in the issue you created during the first challenge (Challenge 1) to demonstrate that you have successfully resolved a merge conflict. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +### Sample Example for merge conflict |
| 44 | +Here is an example of a merge conflict: |
| 45 | + |
| 46 | + |
| 47 | +Step 1: Set Up Your Repository |
| 48 | +a. Create a new directory on your computer for your Git project: |
| 49 | + |
| 50 | +``` |
| 51 | +mkdir merge-conflict-example |
| 52 | +cd merge-conflict-example |
| 53 | +``` |
| 54 | + |
| 55 | +b. Initialize the directory as a Git repository: |
| 56 | + |
| 57 | +``` |
| 58 | +git init |
| 59 | +``` |
| 60 | + |
| 61 | +Step 2: Create Two Branches |
| 62 | +a. Create a new branch called feature-branch: |
| 63 | + |
| 64 | + ``` |
| 65 | + git checkout -b feature-branch |
| 66 | + |
| 67 | + ``` |
| 68 | +b. Create a file and make some changes in it. For example, create a file named example.txt and add the following content: |
| 69 | + |
| 70 | +``` |
| 71 | +This is some content on the feature branch. |
| 72 | +``` |
| 73 | + |
| 74 | +c. Stage and commit your changes: |
| 75 | + |
| 76 | +``` |
| 77 | +git add example.txt |
| 78 | +git commit -m "Add feature branch content" |
| 79 | +
|
| 80 | +``` |
| 81 | +d. Switch back to the main (or master) branch: |
| 82 | + |
| 83 | +``` |
| 84 | +git checkout main |
| 85 | +``` |
| 86 | +e. Make changes to the same file, example.txt, in the main branch. For example: |
| 87 | + |
| 88 | +``` |
| 89 | +This is some content on the main branch. |
| 90 | +``` |
| 91 | + |
| 92 | +f. Stage and commit your changes on the main branch: |
| 93 | +``` |
| 94 | +git add example.txt |
| 95 | +git commit -m "Add main branch content" |
| 96 | +``` |
| 97 | + |
| 98 | +Step 3: Create a Merge Conflict |
| 99 | +a. Attempt to merge the feature-branch into main: |
| 100 | + |
| 101 | +``` |
| 102 | +git merge feature-branch |
| 103 | +``` |
| 104 | + |
| 105 | +At this point, you'll encounter a merge conflict because both branches have made changes to the same part of the example.txt file. |
| 106 | + |
| 107 | + |
| 108 | +Step 4: Resolve the Merge Conflict |
| 109 | +a. Open the example.txt file in your code editor. |
| 110 | + |
| 111 | +b. You'll see Git's conflict markers, which look like this: |
| 112 | + |
| 113 | +``` |
| 114 | +<<<<<<< HEAD |
| 115 | +This is some content on the main branch. |
| 116 | +======= |
| 117 | +This is some content on the feature branch. |
| 118 | +>>>>>>> feature-branch |
| 119 | +``` |
| 120 | + |
| 121 | +c. Manually edit the file to decide which changes to keep. Remove the conflict markers and choose the content you want to keep. For example: |
| 122 | + |
| 123 | +``` |
| 124 | +This is some content on the main branch. |
| 125 | +
|
| 126 | +This is some additional content on the feature branch. |
| 127 | +``` |
| 128 | + |
| 129 | +d. Save the file. |
| 130 | + |
| 131 | + |
| 132 | +Step 5: Commit the Resolved Merge Conflict |
| 133 | +a. Stage the resolved file: |
| 134 | + |
| 135 | +``` |
| 136 | +git add example.txt |
| 137 | +``` |
| 138 | + |
| 139 | +b. Commit the changes: |
| 140 | + |
| 141 | +``` |
| 142 | +git commit -m "Resolve merge conflict" |
| 143 | +``` |
| 144 | + |
| 145 | +Now, you've successfully created a scenario for a merge conflict, resolved it, and committed the changes. You can use these steps as a practical exercise to understand how merge conflicts work in Git. |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
0 commit comments