Collaborating with Others
Objective: The objective of this assignment is to simulate a collaborative Git workflow, where you will work with a team member to develop a project together. You will create, fork, clone, make changes, and merge pull requests to experience the collaborative aspects of Git.
Instructions:
Part 1: Setting Up the Project
1. Task 1: Create a new public repository on GitHub named "CollaborationProject."
2. Task 2: Clone the "CollaborationProject" repository to your local machine.
git clone https://github.com/your-username/CollaborationProject.git
3. Task 3: Navigate to the project directory.
cd CollaborationProject
4. Task 4: Create a new file named "index.html" in the project directory.
touch index.html
5. Task 5: Add some HTML content to "index.html."
html
<!DOCTYPE html>
<html>
<head>
<title>Collaboration Project</title>
</head>
<body>
<h1>Welcome to our collaboration project!</h1>
</body>
</html>
6. Task 6: Commit the changes to the repository.
git add index.html
git commit -m "Initial commit: Add index.html"
7. Task 7: Push the changes to the remote repository on GitHub.
git push origin main
Part 2: Collaborating with a Team Member
1. Task 1: Collaborator: Invite a classmate or a friend to collaborate on this project. Your collaborator should accept the invitation and clone the repository to their local machine.
2. Task 2: Collaborator: Make a change to the "index.html" file. Add some additional content or make edits.
3. Task 3: Collaborator: Commit your changes and push them to the remote repository.
4. Task 4: Collaborator: Create a new branch with a meaningful name for your changes.
git checkout -b feature/your-feature-name
5. Task 5: Collaborator: Push the new branch to the remote repository.
git push origin feature/your-feature-name
Part 3: Reviewing and Merging Changes
1. Task 1: Project Owner: Review the changes made by the collaborator in the pull request on GitHub.
2. Task 2: Project Owner: If the changes are satisfactory, merge the pull request into the "main" branch using GitHub's interface.
3. Task 3: Collaborator: Pull the latest changes from the remote repository to your local machine.
git pull origin main
4. Task 4: Collaborator: Switch back to the "main" branch.
git checkout main
5. Task 5: Collaborator: Update your local "main" branch with the changes from the remote repository.
git pull origin main
Solutions
Part 1: Setting Up the Project
# Task 1: Create the GitHub repository (via the GitHub website)
# Task 2
git clone https://github.com/your-username/CollaborationProject.git
# Task 3
cd CollaborationProject
# Task 4
touch index.html
# Task 5
# Add content to index.html
# Task 6
git add index.html
git commit -m "Initial commit: Add index.html"
# Task 7
git push origin main
Part 2: Collaborating with a Team Member
No specific commands provided as this part involves collaboration between team members. Your collaborator will perform the necessary Git commands.
Part 3: Reviewing and Merging Changes
No specific commands provided as this part involves reviewing and merging changes via GitHub's interface.