Skip to content

Instantly share code, notes, and snippets.

@christianmalek
Forked from fetttobse/how_to_git.md
Created July 2, 2017 12:47
Show Gist options
  • Save christianmalek/e17ea4b825fbd573369efabe833fe9e3 to your computer and use it in GitHub Desktop.
Save christianmalek/e17ea4b825fbd573369efabe833fe9e3 to your computer and use it in GitHub Desktop.
How to git in agile projects

How to Git

A Git workflow for agile development.

Step 1: Pull from master

First pull from master, to have the latest version of the repo: git pull origin master

Step 2: Checkout a feature branch

Checkout a feature branch, name it with the issue id of the story you are working on and a short description. For example if you are working on #42: User can upload pictures, do something like git checkout -b 42-picture-upload NOTE: Git does not allow spaces in branch names, so seperate with - or _!

Step 3: Commit early and often

Do your work and commit whenever somethin is working (yay!). Always include the issue id in your commit messages and write a understandable commit message which makes sense. Otherwise pay the rest of the team some coffee! git commit -m "#42 Added upload dialogue to gallery.html

Step 3a: Rebase frequently

Otherwise it may kill you. git fetch origin master git rebase origin/master

Step 3b: Squash, if you are a pussy

If you want to hide the hundreds of stupid commits needed to implement a simple feature, squash them together. git rebase -i origin/master In the now magically opened file change the pick in front of the unwanted commits to squash, they will be squashed. Save and close. In the next view enter a new commit message and save and close again.

Step 4: Merge to master

Done with your feature? Great. Of course you tested a lot and now are ready to merge the branch back to master. git checkout master git merge 42-picture-upload Don't forget to push the master branch back to your remote.

How to deal with issues

Bugs should be tracked in issues, so they have their own issue id. Follow the same workflow as above, use the bugs issue id as branch number. Add a prefix like bug- or hotfix- to make everything clear.

By fetttobse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment