Git Workflow

This is a general step by step of my Git workflow. I know this is an overkill for one person operation but I guess I need to prepare myself in working as a team. The idea is using branch for every changes I want to make and merge back to master. I have used this in multiple laptop and developing/fixing different functionalities in parallel (yes I know it sounds weird).

So far so good but I have not really tested it for working with people. So here is the recipe:

// make sure I am in the correct branch
$ git checkout master

// bring your master repository up to date with a master remote repository
// in short “git pull” does a “git fetch” followed by a “git merge”.
// if you want to err on the safe side, do “git fetch” followed by “git merge”
$ git pull

// think of what to do. say “Task A”
$ git checkout -b task_a

// do something. write test. commit regularly. push to repo (push the branch not master)
// when everything is done

// back to master
$ git checkout master

// bring your master repository up to date with a master remote repository
$ git pull

// go back to task_a branch
$ git checkout task_a

// merge any changes on master to task_a
$ git rebase master

// depending on how good or bad the situation, you might need to resolve some stuff here
// google is your good friends, test stuff is awesome
// the idea is that it is better to resolve shit on branch than master
// repeat this master pull and rebase several times
// do not forget to commit stable branch

// once everything is ok
$ git checkout master
$ git merge task_a
$ git push

//YAY

//Optional: tag it
$ git tag -a v0.01-special-release -m “After do task A”
$ git push –tags

Main inspiration: http://longair.net/blog/2009/04/16/git-fetch-and-merge/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>