diff --git a/README.md b/README.md index d027d6e..0f3d06f 100644 --- a/README.md +++ b/README.md @@ -11,25 +11,35 @@ By the end of this tutorial, you should be able to: 1. Clone a repository. 2. Make changes and push them. -3. Resolve merge conflicts. -4. Use the rebase command. -5. Raise a pull request (PR). +3. Raise a pull request (PR). +4. Resolve merge conflicts. ### Let's Get Started! -#### 1. Clone the Repository: +#### 1. Fork the Repository: -Start by cloning the existing repository. This repository is located on a remote server, which is typically GitHub for most projects. By cloning it, you create a local copy on your machine which you can edit and push back to the remote repository. +Start by forking the existing repository. This repository is located on a remote server, which is typically GitHub for most projects. By forking it, you create a local copy which you can edit and push back to the remote repository. + +> When you fork the project, make sure to unselect the option to Copy the main branch only only + +Next clone the repo + +```bash +$ git clone https://github.com/[YOUR_GITHUB_ID]/Introduction_to_Git/ +``` + +If you check the repo, you'll find two branches `main` and `dev` (You may not see the `dev` branch since it's remote) ```bash -$ git clone https://github.com/Waseem0912-coder/Introduction_to_Git +$ git branch --list ``` #### 2. Create a New Branch: -To avoid conflicts with the main codebase, always work on a new branch. +Checkout out the `dev` branch and then create a new branch from dev using the following command ```bash +$ git checkout dev $ git checkout -b [your_name]-choice ``` @@ -37,9 +47,8 @@ Replace `[your_name]` with your actual name. #### 3. Choose Your Greek God: -Open the provided text file in the repository. Choose one Greek god from the following list and add it to the file: +Open the provided text file `greek_gods.tx` in the repository. Choose one Greek god from the following list and add it to the file: -- Zeus - Hera - Poseidon - Demeter @@ -64,24 +73,21 @@ $ git commit -m "Chose my Greek god" $ git push origin [your_name]-choice ``` -#### 5. Rebase: +#### 5. Raise a Pull Request: -Before raising a PR, ensure your branch has the latest changes from the main branch of the remote repository. Rebasing allows you to apply your changes on top of the latest changes in the main branch. +Now, return to the GitHub repository online: -```bash -$ git checkout main -$ git pull origin main -$ git checkout [your_name]-choice -$ git rebase main -``` +1. Click on "Pull Requests". +2. Select "New Pull Request". +3. For the base branch, choose "main". For the compare branch, pick your branch (`[your_name]-choice`). +4. Review your changes and click "Create Pull Request". +5. Add a title and description for your PR and submit. -If you encounter conflicts during the rebase (which is expected given the Greek god choice), proceed to step 6. If not, move on to step 7. +If you encounter conflicts during the PR (which is expected given the Greek god choice), proceed to step 6. #### 6. Resolve Merge Conflicts: -Multiple students might have chosen the same Greek god, leading to a merge conflict. - -Open the text file, and you'll see conflict markers: +Open the text file on GitHub by selecting the option to `Resolve Conflicts`, and on the web editor you'll see conflict markers: ``` <<<<<<< HEAD @@ -93,29 +99,10 @@ Athena To resolve this: -1. Decide which choice to keep or combine them. +1. Decide which choice to keep or combine them (in this case, keep your changes). 2. Remove the conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`). 3. Save the file. -After resolving all conflicts: - -```bash -$ git add . -$ git rebase --continue -``` - -If more conflicts arise, resolve them. Once there are no more conflicts, the rebase will conclude. - -#### 7. Raise a Pull Request: - -Now, return to the GitHub repository online: - -1. Click on "Pull Requests". -2. Select "New Pull Request". -3. For the base branch, choose "main". For the compare branch, pick your branch (`[your_name]-choice`). -4. Review your changes and click "Create Pull Request". -5. Add a title and description for your PR and submit. - ---- +After resolving all conflicts, create the PR Congratulations! You've now tackled changes, navigated conflicts, and initiated a PR. Handling merge conflicts can seem daunting at first, but with practice, it becomes intuitive. This exercise imparts the collaborative flow of team projects using Git and GitHub, enhancing your version control skills. diff --git a/greek_gods.txt b/greek_gods.txt index e69de29..bbc0f1e 100644 --- a/greek_gods.txt +++ b/greek_gods.txt @@ -0,0 +1,2 @@ +Zeus +Ares \ No newline at end of file