Collaborative Workflow with Forking and Pull Requests

Let's go through a practical step by step process, from forking the repository to creating a feature branch, making changes, and finally submitting a pull request for review and merging.


Let's imagine that Alice, a developer, wants to contribute to an open-source project called "AwesomeApp." The project is hosted on a platform like GitHub, which supports the forking and pull request workflow.

Step 1: Forking the Repository

To contribute to "AwesomeApp," Alice needs to fork the repository. Forking creates a copy of the project under Alice's GitHub account, allowing her to freely make changes without affecting the original codebase.

  • Alice goes to the "AwesomeApp" repository on GitHub.

  • She clicks on the "Fork" button in the top-right corner of the repository page.

  • GitHub creates a copy of the repository under Alice's GitHub account.

Step 2: Cloning the Forked Repository

After forking the repository, Alice needs to clone it to her local machine to start working on the changes.

  • Alice opens a terminal on her machine.

  • She uses the following Git command to clone the forked repository

git clone

Note: Replace "Alice" with her GitHub username.

  • The repository is now cloned to Alice's local machine.

Step 3: Creating a Feature Branch

To make changes to the project, Alice should create a new branch dedicated to her feature or bug fix.

  • Alice navigates into the cloned repository's directory:

cd AwesomeApp
  • She creates a new branch, naming it descriptively:

git checkout -b alice-add-new-feature

This command creates and switches to the new branch, alice-add-new-feature

Step 4: Making Changes

Now that Alice has created a feature branch, she can start making the desired changes to the codebase.

  • Alice opens the code files using her preferred text editor or IDE.

  • She makes the necessary modifications, adds new functionality, or fixes bugs.

Step 5: Committing Changes

Once Alice has made the desired changes, she needs to commit them to the feature branch.

  • Alice stages the changes she made:

git checkout -b alice-add-new-feature
  • This command stages all the modified and new files for commit.

  • She commits the changes with a descriptive message:

git commit -m "Add new feature: XYZ"

Replace "XYZ" with a brief description of the added feature.

Step 6: Pushing the Feature Branch

After committing the changes locally, Alice needs to push the feature branch to her forked repository on GitHub.

  • Alice pushes the feature branch:

git push origin alice-add-new-feature
  • This command pushes the branch to Alice's forked repository.

Step 7: Creating a Pull Request

Now that Alice has pushed her feature branch, she can open a pull request to propose the changes to the original "AwesomeApp" repository.

  • Alice navigates to her forked repository on GitHub.

  • She clicks on the "New Pull Request" button near the top of the repository page.

  • GitHub compares the changes in Alice's feature branch with the main branch of the original repository.

  • Alice reviews the changes, adds a descriptive title and comment, and clicks on the "Create Pull Request" button

Step 8: Review and Merge

After Alice has created the pull request, the project maintainers will review her changes and decide whether to merge them into the main codebase.

  • The maintainers of "AwesomeApp" receive a notification about the new pull request.

  • They review the proposed changes, provide feedback, and discuss any necessary modifications with Alice through comments.

  • Alice can continue making changes and pushing them to the feature branch based on the feedback until the pull request is approved.

  • Once the maintainers are satisfied with the changes, they merge Alice's pull request into the main branch of "AwesomeApp."

  • Alice's contribution is now a part of the project, and her feature is available to all users of "AwesomeApp."

Last updated