Fork me on GitHub

12/30/2011

Using Git In Non Merging Way

Here is the flow I used in the past few months development wit Git

  1. First, create a branch 'base' to track the remote collaborating branch

    $ git checkout -b base -t origin/trunk
        // create a local branch 'base' to track a remote branch 'origin/trunk'
    $ git branch -a
        // show the detail info about local/remote branches
    $ git remote show origin
        // to know which local branch tracks which remote branch, see the bottom of output
    
  2. Any feature/hotfix are checkout to a separate feature branch from base branch, and develop on it

    $ git checkout -b 1201-fea
        // create a local branch for development
    
  3. After completing and verifying your changes, patch your changes

    $ git diff > p1225_refactor
        // output your changes to a patch file names 'p1201_fea'
    
  4. When ready to sync changes to server, update your base branch, checkout to it, then apply your patch

    $ git checkout base
    $ git pull --rebase
        // make sure the branch in the updated condition
    $ git apply p1225_refactor
        // apply your changes on top of it
    
  5. The habits which prevent you from the regular loop of conflict and merge

    Often update your 'base' branch, don't let it lag too much behind the remote trunk

    If your changes are not urgent, keep checking out a daily experiment branch from 'base' and try to apply your patch and verify it. If any conflict, you can fix it as early as posiible

    Naming your branches and patches clearly, give them some identifiable prefix or suffix

-- EOF --

No comments:

Post a Comment