Git Workflow(Collaboration)
Git workflow
Centralized workflow
AKA everyone works on master/main AKA the most basic workflow possible
The simplest collaborative workflow is to have everyone work on the master branch (or main,or any other single branch).
It's straightforward and can work for tiny teams,but it has quite a few shortcoming
Feature branches
Rather than working directly on master/main, all new development should be done on separate branches !
Multiple teammates can collaborate on a single feature branch and share code back and forth without puooluting the master/main
master/main branch won't cotianer broke code (or at leats,it won't unless someone mess up)
Feature branch naming
There are many different approaches for naming feature branhes. Ofter you'll see branch names that include slashes like bug/fix-scroll
or feature/login-form
or feat/button/anable-point-event
.
Special teams and projects ussually have their own branhc naming convertions. To keep these slides simple and concise,i'm just going to ignore those best-practices for now.
Merging in feature branches
At some point new the work on feature branches will need to be merged in to the master branch !There are a coiple of options how to do this ...
Merge at will, withour any sort of discusssion with teammates.JUST DO IT WHENEVER YOU WANT.
Send an emaill or chat message or something to your team to discuss if the changes should be merged in
Pull Request
Pull Request
Pull request are a feature built in to products like github & githucket. THey are not native to git itself
They allow developers to alert team-members to new work that need to be reviewd. They provide a machism to approve or reject the work on a given branch. They also help facilitate discussion and feedback on specified commits
The workflow
Do some work locally on a feature branch
Push up the feature to github
open a pull request using the feature branch just pushed up to github .
Wait for the PR to be approve and merged . Start a discussion on the PR. this part depend on the team structure .
Fork Pull
A fork in Git is simply a copy of an existing repository in which the new owner disconnects the codebase from previous committers. A fork often occurs when a developer becomes dissatisfied or disillusioned with the direction of a project and wants to detach their work from that of the original project.
To summarize
I fork the original project repo on github
I clone my fork to my local machine
I add a remote pointing to original project repo. the remote is often named upstream
I make changes and add/commit on a featur branch on my local machine
i push up my new feature branch to my my forked repo (ussually called origin)
I open a pull request to the original project repo containing the new work on my forked repo
Hopefully the pull request is accepted and my changes are marrged in !
Last updated