Git WorkFlow For the Everyday Joe
Ill attempt to describe the basic workflow used on 98% of projects Ive worked on in the past few years in simple terms with some examples. There are a few concepts to keep in mind that will make life simpler.
First the master branch is always deployable. Its the golden standard you should always be able to branch from and deploy patches.
Second, feature branches and commits should always (ahem yeah I know) be related to a single request.
Thirdly, try to keep your branches merged on a semi-regular basis. The longer they sit out there the more it takes to merge them back in.
Finally, keep it simple. The more complexity you add, the more you and your team have to deal with. The longer it takes to deploy fixes, the longer it takes to onboard developers.
Here is what is going on in Pseudo code
- Create your git clone on you local machine
- Sync your local git with the remote
- When you want to change make a remote branch
- When you are ready to share make a pull request
- Ask others to review your pull request and get approval
- Merge you code into master
Here is a more detailed syntax view
# clone the repogit
clone [email protected]:MyAwesomeProject/MyAwesomeProject.git# cd into development directorygit pull
# now you are in synch with the remote origin
# make a feature branch with first&lastintial_name.
# This is arbitrary there can be any naming convention.
git push origin master:yourintials-myawesomefeature
git checkout -t origin/yourintials-myawesomefeature
# do stuff
# add your changes to local git indexgit add .
# commit your changes with a comment
git commit -m “I changed cool stuff”
git push origin yourintials-myawesomefeature
After everything is pushed to Github you can login and create a pull request. Just add your comments and verify everything is what is what you intended to push. Once you are ready send the link for a review like this:
You can review my pull request at
At this point everyone reviews and gives comments. Its much more than likely you will need to make adjustments from the comments dont sweat it, just correct it then do the add/commit/push loop again. Once its approved lets get ready to merge.
git checkout master
# double check you aren’t behind.
git merge -m “If fixed XYZ”
Keep in mind by the time you have developed your feature and get ready to merge you could be out of sync with the master branch. These inconsistencies will need to be resolved then go through the add/commit/push loop again
I realize this is Github centric, but the concepts work anywhere. None of this is set in stone, feel free to suggest changes or offer different alternatives. There are many ways to work in a team environment, do what works for you.