Skip to content

Instantly share code, notes, and snippets.

@Strikeskids
Created May 16, 2015 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Strikeskids/fe5c77868808b274fb24 to your computer and use it in GitHub Desktop.
Save Strikeskids/fe5c77868808b274fb24 to your computer and use it in GitHub Desktop.
Git Flow

The basic steps are listed below. They are described in more detail afterwards.

  1. Update master
  2. Use a work branch
  3. Clean up your work before sharing
  4. Pull request so that people get notified (or merge)
  5. Clean up your workspace to start again

When doing work, always make sure to update and checkout a new branch. This way, we keep the main branch clean.

git checkout master
git pull origin master
git checkout -b my-work-branch

Before committing to the main branch, clean up your work and make sure it will fit in nicely

git checkout master
git pull origin master
git checkout my-work-branch
git rebase --interactive master

Repeat the rebase until you have achieved work that follows a nice linear history. Make sure that you are only committing the files that you want to be committed, and not some other strange files. You really should be git adding the files and not git commit -a of all the files.

After your work is nice and rebased after the most recent master, pull request the changes so that everyone else who is working gets notified.

git push origin my-work-branch

On github, pull request with master as the main branch and your work branch as the compare branch. If it says that your branch cannot be automatically merged, then you did something wrong. Get rid of your remote branch

git push origin :my-work-branch

and try the clean-up steps again (pull origin master and rebase --interactive master).

Alternatively, merge your stuff locally and then push to master

git checkout master
git merge --no-ff my-work-branch
git push origin master

If there are ANY conflicts in the push, reset your master to before the merge commit and pull from the remote again.

Once you automatically merge your work branch, make sure to delete it either from the github interface or locally.

Then, clean up your workspace.

git checkout master
git pull origin master
git branch --delete my-work-branch

Your dear friend

git log --decorate --oneline --graph

This will help you figure out what is happening in the git history in order to fix stuff.

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