JonathanAnderson Git Workflow
This is how JonathanAnderson currently uses Git for FreeBSD development. It is unlikely to be the best way.
- Get the complete revision history of the project (~800 MB, but you only have to do this the slow way once):
If I don't have a copy lying around:
git clone git://git.freebsd.your.org/freebsd.git
- If I do have a copy on the same network:
git clone git://localserver/path/to/freebsd.git git remote rm origin git remote add origin git://git.freebsd.your.org/freebsd.git git pull
optional: if you're tracking a branch other than -CURRENT:
git checkout remotes/origin/vendor/sendmail/8.9.3
(or remotes/origin/release/8.2.0, or remotes/origin/user/sam/wifi...)
Create a new branch for hacking on:
git checkout -b newfeature
- hack hack hack, commit byte-sized chunks to local repo, repeat
Stay on top of -CURRENT (spelled master in Git), or remote/origin/vendor/foo, or what have you:
git checkout master git pull git rebase master newfeature
Prettify the patch stream:
git branch new-feature-prettified master git cherry-pick ac238e # grab a commit from 'newfeature' git checkout newfeature sys/kern/vfs_syscalls.c # grab a file 'newfeature' HEAD git checkout newfeature~6 sys/kern/foo # six commits ago on 'newfeature' git checkout ac238e sys/kern/foo # grab a file from a particular commit
- Reduce the unprettified branch to "stuff I haven't prettified yet":
git rebase new-feature-prettified newfeature
If there are conflicts:
git add sys/kern/fixed.c && git commit && git rebase --continue
If a commit has been subsumed by the prettified branch (git status is empty):
git rebase --skip
Produce a patch stream for non-Git people:
git checkout new-feature-prettified git format-patch master scp *.patch somewhere:~/foo
- Commit the result
- FOR NOW: apply patches to an SVN checkout and submit them the old-fashioned way
IN FUTURE: use a variant of a command
git svn commit-diff -m "git branch to svn" -rHEAD upstream/master work/ hwpmc_kcachegrind svn+ssh://svn.freebsd.org/base/user/fabient/svctest/
This workflow says nothing about maintaining a public-facing Git branch on e.g. Github. That requires a lot more merging and a lot less rebasing.