- A centralized Git workflow enables all team members to make changes directly to the main branch or default branch), with every change logged in a running history. A centralized workflow involves every contributor committing to the main branch without using any other branch.
- This strategy works well for small teams, because team members can communicate so that multiple developers aren’t contributing to the same piece of code simultaneously.
- Suppose Developer A and B are working using this workflow, At first both will have same branches in their local machine. Now Dev-A does some changes and pushes to Github. Mow Dev-B cannot directly push his changes. First he need to pull the changes done by Dev-A.
Feature branching Git workflow:
- Rather than working directly on Main, all new development should be donw in seperate branches.
- Ideally, a feature branch should have a lifespan of a few hours. The longer the branch lives, the higher the risk to find integration conflicts when merging back to main.
- Merge can be done using merge command or pull request.
Pull Request:
- This is a built in feature of github and not native to git.
- They allow developers to alert team-members to new work that needs to be reviewed. They provide a mechanism to approve/reject the work on a given branch.
FORKING:
- Github allows us to create personal copies of other people repo. We call those copies a fork of the original. This is a Github feature.
Fork and Clone:
- The fork and clone workflow is a common pattern in GitHub when working on open source projects. Here's how it works:
- Fork the original repository: This creates a copy of the repository in your GitHub account, allowing you to make changes without affecting the original repository.
- Clone the forked repository: This creates a local copy of the repository on your computer, so you can start making changes.
- Make changes to the cloned repository: You can add, edit, or delete files, and commit your changes to the local repository.
- Push changes to the forked repository: Once you're satisfied with your changes, you can push them to the forked repository in your GitHub account.
- Submit a pull request: Finally, you can submit a pull request to the original repository, asking the owner to merge your changes into the main codebase.