Exercise 2
Welcome to the Git Essentials second exercise! In this exercise, you'll dive into resolving merge conflicts in a collaborative Git environment. The focus will be on updating personal information in a shared file, generating merge conflicts, and exploring different conflict resolution strategies. Here's the tasks you'll be performing:
- Clone Repository
- Add Personal Information
- Create Pull Requests
- Resolve Merge Conflicts
- Rebase, Squash, and Merge
- Commit History and Interactive Rebase
Instructions
-
Updating Your Profile:
- Your task is to update the
gdsc.txt
file in repositories belonging to your fellow participants. Add your name, occupation, favorite hobby, and something you dislike to theirgdsc.txt
.
- Your task is to update the
-
Creating Pull Requests:
- Initiate a Pull Request in the repository you're modifying, aiming to update the
gdsc.txt
file. - Ensure your PR clearly states the purpose: "Adding Personal Information."
- Initiate a Pull Request in the repository you're modifying, aiming to update the
-
Simulating Merge Conflicts:
- Your goal is to make changes to the same line or section of the
gdsc.txt
file in repositories of other participants. - When your PRs are submitted, try merging them into your repository. You may face merge conflicts due to changes in the same sections of the file.
- Your goal is to make changes to the same line or section of the
-
Resolving Conflicts:
- Use Git commands (
git status
,git diff
,git checkout --ours/--theirs
) to identify conflicting sections. - Discuss and communicate effectively with the repository owners to decide on retaining specific changes.
- Resolve conflicts either by manual editing or using Git tools, ensuring file consistency and preventing data loss during conflict resolution.
- Use Git commands (
-
Exploring Git Strategies:
- Experiment with different merge strategies (merge, rebase, squash) while integrating changes from the main repository.
- Consider the advantages and limitations of each strategy in managing conflicts and maintaining a clean commit history.
-
Reviewing Commit History and Interactive Rebase:
- Analyze commit history using
git log
. - Learn about interactive rebase by renaming a commit, squashing, or rearranging commits based on a previous commit.
- Analyze commit history using