TubeTK/Development/GITConfiguration

From KitwarePublic
< TubeTK‎ | Development
Revision as of 20:48, 7 November 2010 by Aylward (talk | contribs) (Created page with "= Scripted git commands for a linear history = * All developments MUST use the following scripts and workflow to maintain a linear git history in TubeTK * These scripts are publ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Scripted git commands for a linear history

gitupdate (script)

#!/bin/sh -x
# hack: Merge the latest changes from the master branch into your current branch
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 0
CURRENT="${ref#refs/heads/}"
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master

gitship (script)

#!/bin/sh -x
# Git workflow ship script from: http://reinh.com/blog/2008/08/27/hack-and-and-ship.html
# git name-rev is fail
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 0
CURRENT="${ref#refs/heads/}"
git checkout master
git merge ${CURRENT}
git push origin master
git checkout ${CURRENT}

Using the Scripts

The above scripts should be used in a workflow as:

> git branch *newTopic*
> git checkout *newTopic*
> *do some work*
> git add *files*
> git commit *files*
> gitupdate
> *do some more work*
> git add *files*
> git commit *files*
> gitupdate
> gitship

Hidden details

  • The above scripts and workflow implement the following, and save you much typing and potential errors!
  • Most importantly, do your work in branches, not in master!
  1. Keep a local master branch which only is a pointer to the gitorious master (does not contain local changes)
  2. Make development modification in a local branch
  3. When getting ready to push these changes to the origin try the following
    1. Do a git pull on master to fetch and merge all changes from gitorious
      1. git checkout master
      2. git pull origin master
    2. Do a git rebase of the topic branch onto master - That is with topic checkout do "git rebase master"
      1. git rebase master topic
    3. Fix any conflicts that result
      1. Edit files
      2. git add -u
      3. git rebase --continue
    4. Merge the topic branch - This will result in an fast-forward merge.
      1. git merge topic
    5. git push your local master branch
      1. git push origin master