This is how JonathanAnderson currently uses Git for FreeBSD development. It is unlikely to be the best way.

  1. Get the complete revision history of the project (~800 MB, but you only have to do this the slow way once):
    1. If I don't have a copy lying around:
git clone git://git.freebsd.your.org/freebsd.git}}}
  A. If I do have a copy on the same network:
   i. {{{
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
  1. 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}}}...)
 2. Create a new branch for hacking on: {{{
git checkout -b newfeature}}}
 3. hack hack hack, commit byte-sized chunks to local repo, repeat
 4. 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}}}
 5. 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}}}
 6. Reduce the unprettified branch to "stuff I haven't prettified yet":
  A. {{{
git rebase new-feature-prettified newfeature
  1. If there are conflicts:
git add sys/kern/fixed.c && git commit && git rebase --continue}}}
  A. If a commit has been subsumed by the prettified branch ({{{git status}}} is empty): {{{
git rebase --skip}}}
 7. Produce a patch stream for non-Git people: {{{
git checkout new-feature-prettified
git format-patch master
scp *.patch somewhere:~/foo}}}
 8. Commit the result
  A. FOR NOW: apply patches to an SVN checkout and submit them the old-fashioned way
  A. 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.

  • jonathanandersongitflow.txt
  • Last modified: 2026/10/12 10:55
  • (external edit)