Skip to the content.

GIT: Basic collaboration

- -

Fork and Pull

The fork and pull request method is a popular approach for managing Git repositories within a team on a collaborative project, especially when using platforms like GitHub, GitLab, and Bitbucket. This method allows team members to work on a shared project without direct write access to the original repository. Here’s how it works:

-

Fork the Original Repository:

A team member starts by creating a personal copy (fork) of the original repository. This forked repository is typically hosted on the same platform as the original (e.g., GitHub).

-

Clone the Fork:

The team member clones their fork to their local development environment using Git. This local copy allows them to make changes and contributions to the project.

-

Create a Feature Branch:

Before making changes, the team member creates a new branch in their local repository. This branch is usually named after the feature or issue they are working on.

-

Make Changes and Commit:

The team member makes changes to the code, adds, commits, and tests those changes on their local branch. They can push these changes to their forked repository when they’re ready.

-

Create a Pull Request:

To propose changes back to the original repository, the team member initiates a pull request (PR) in the original repository. The pull request is created on the platform hosting the original repository.

-

Review and Collaboration:

Other team members and maintainers of the original repository can review the changes made in the pull request. They can discuss, suggest improvements, and collaborate on the code. Automated testing and continuous integration (CI) systems can run tests on the code to ensure it doesn’t introduce issues.

-

Merge the Pull Request:

If the changes are approved and meet the project’s coding standards and requirements, the pull request is merged into the original repository. The changes are now part of the official project.

-

Keep Fork Synchronized:

To keep their fork up-to-date with the original repository, the team member periodically fetches changes from the original repository and rebases their local branches.

-

Repeat the Process:

Team members continue working on new features or fixing issues by creating additional branches, making changes, and creating pull requests.

Workflow advantages of Fork/Pull

The fork and pull request workflow is advantageous for several reasons:

This workflow is commonly used in open-source projects, but can be adapted for private or internal development. It promotes effective collaboration, version control, and quality assurance in software development.