# Collaborative Workflows - Forking, Branching, and Pull Requests

Let's explore how these workflows facilitate collaboration, enable parallel development, and simplify the process of integrating changes into a shared codebase.

#### Forking a Repository and its Benefits

When you want to contribute to a project hosted on a version control system like Git, forking provides a way to create your own copy of the project. This allows you to freely experiment, make changes, and propose modifications without affecting the original repository. Here's a step-by-step guide on forking a repository

* Navigate to the repository on a platform like GitHub.&#x20;
* Click on the "Fork" button to create a personal copy of the repository.&#x20;
* Once the forking process completes, you will have your own version of the repository hosted on your GitHub account.

**Benefits of forking**

* You gain complete control over your forked repository.
* You can freely experiment with changes and modifications.
* It enables you to contribute to the original repository via pull requests.

#### Collaborative Workflows using Branches and Pull Requests

Branching is a powerful feature in Git that allows for parallel development by creating independent lines of development. A branch is essentially a separate pointer to a commit, enabling you to make changes and commit them without affecting the main branch (often called the "master" or "main" branch). Here's how you can work with branches:

#### Create a new branch

```
git branch my-feature
git checkout my-feature
```

#### Make changes on the branch and commit them

```
git add .
git commit -m "Implement new feature"
```

#### Push the branch to your forked repository

```
git push origin my-feature
```

Pull requests are the primary method of proposing changes to a repository. They allow you to notify the repository maintainers about your changes and initiate a discussion for their review. Here's a step-by-step guide on working with pull requests:

* Navigate to your forked repository on Github
* Click on the "New pull request" button.
* Select the appropriate base branch (usually the main branch of the original repository) and the branch containing your changes.
* Provide a clear title and description for your pull request, explaining the changes you made.
* Submit the pull request and wait for the maintainers to review it.

***

### Submitting and Reviewing Pull Requests

When you submit a pull request, it initiates a review process where maintainers and other contributors can provide feedback on your changes.&#x20;

They can review the code, suggest modifications, and discuss the proposed changes directly on the pull request. Here's how to effectively submit and review pull requests:

**As a contributor**

* Clearly explain the purpose and motivation behind your changes in the pull request description.
* Respond promptly to feedback and address any requested modifications.
* Collaborate with reviewers to ensure your changes align with the project's standards and goals.

**As a reviewer**

* Review the proposed changes carefully, examining the code, documentation, and tests
* Provide constructive feedback, focusing on clarity, correctness, and adherence to project guidelines.
* Engage in discussions to help refine the changes and guide the contributor towards improvements.
