Skip to content
Riyaz Ali
Go back

Git Workflow

In this post I’m going to write about the fork-clone-pull that we’ve been using for some time now at work.

To begin with, the Fork workflow (just workflow from now on) extend Github’s Workflow and adds forking to the mix..

And why do that?

Several benefits.

Convinced? nice! read ahead to know more about how to implement..

Implementation

git clone git@github.com:user/repo
git remote add upstream git@github.com:organisation/repo
git checkout -b feature/the-next-big-stuff
git push -u origin HEAD

Keeping the code in sync

When multiple developers are working on a project it’s very likely that the upstream would move much faster than the devs’ origin. In that case, the dev would need to periodically (ideally, they should do it daily) sync their origin with the upstream.

To do that, devs need to execute following (on their local machine) -

# fetch upstream and all branches
> git fetch upstream
# checkout local or own develop
> git checkout develop
# get the changes from the upstream and merge to your local.
> git merge upstream/develop
# push the code to the develop branch of your fork
> git push origin develop

The devs should also execute ☝️ once they’ve their PR merged.


And that’s it! you’ve got a scalable git workflow model that would work well even for remote teams (we’ve used it quite extensively!)..

And just to make it clear.. we are not the first ones who’ve used this or anything like that 😛.. this flow is used extensively in open-source world where generally there is a central upstream canonical repository (where all issues are made and project is released) and each contributor has his/her own “fork” of that repository. The beauty of this flow is that it scales so well even for a highly distributed open source project!

References



Previous Post
Design Docs
Next Post
Why documentation matters