Resolving Git Conflict and Finalizing Updates
Overview
During a routine update to the story-blog
project, I encountered a Git merge conflict while attempting to push local changes to the remote repository. This conflict occurred in the story-index.txt
file due to concurrent updates made by Max and Sarah.
The local changes included the addition of two new story titles and a typo fix in The Lion and the Mouse. The remote repository already contained two story titles previously pushed by Sarah. To ensure the repository maintained all contributions, I successfully resolved the conflict, finalized the content, and pushed the updates.
What I Completed
-
Resolved Git merge conflict in
story-index.txt
- Combined story titles from both local and remote versions
- Corrected a typo: Changed "Mooose" to "Mouse" in The Lion and the Mouse
- Committed and pushed the final, clean version to the remote repository
- Verified updates via the Gitea web interface
Steps Followed
Attempted to Push Changes
While in /home/max/story-blog
, I ran:
git push
- Resulted in an error:
Updates were rejected because the remote contains work that you do not have locally.
Pulled Latest Remote Changes
git pull
- This triggered a merge conflict in the
story-index.txt
file due to overlapping additions.
Opened and Resolved Conflict
vi story-index.txt
Conflict markers appeared. Below is an example of a format you will see:
<<<<<<< HEAD
1. The Fox and the Grapes
2. The Tortoise and the Hare
=======
1. The Lion and the Mouse
2. The Ant and the Grasshopper
>>>>>>> origin/master
I manually edited the file to combine both versions, resulting in such an example:
1. The Fox and the Grapes
2. The Tortoise and the Hare
3. The Lion and the Mouse
4. The Ant and the Grasshopper
Saved and exited the editor.
Corrected Typo in Story File
Opened the relevant file and fixed the typo:
nano the-lion-and-the-mooose.txt
- Replaced "Mooose" with "Mouse"
- Saved and exited
Staged and Committed the Merge
git add story-index.txt
git commit -m "Resolved merge conflict in story-index.txt and fixed typo"
Pushed Final Updates
git push origin master
- The push was successful, and all changes were uploaded to the remote repository.
Verified in Gitea Web UI
- Logged in to Gitea as user
max
- Opened the
story-blog
repository -
Confirmed:
-
story-index.txt
now lists all 4 story titles - The typo in The Lion and the Mouse is fixed
- The latest commit is reflected in the commit history
-
Conclusion
This task emphasized the importance of careful conflict resolution in collaborative Git environments. All changes from both contributors have been preserved and are now properly reflected in the repository. The story-blog
project is up to date, clean, and ready for further development.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.