[Insight-developers] Learning from my mistakes (an adventure in git)
Stephen Aylward
stephen.aylward at kitware.com
Sat Jul 31 14:01:09 EDT 2010
Seems like a great posting for the ITK git FAQ!
Congrats on the creative exit strategy!
I am constantly going through love/hate cycles with git. Deep down I
love git, but occasionally git acts like a spoiled child - requiring
very obscure paths to get what you want our of them.
s
On Sat, Jul 31, 2010 at 12:35 PM, Hans Johnson <hans-johnson at uiowa.edu> wrote:
> First let me preface this story: I am really liking git. I am now starting
> to see the tremendous power that git is going to provide in managing
> contributions from multiple developers efficiently. But as spider man’s
> uncle ben stated “With great power comes great responsibility”.
>
> This is documentation of how I dug myself out of a big git hole.
>
> Did you ever work yourself into a "git" hole so deep that you want to just
> start over? I did!
> While I was fumbling around in trying every nifty git feature I came across,
> I ended up with such
> a mess that I could not find an elegant way to get out of it.
>
> Here is what I did after getting scared that all the coding work I did was
> going to be lost due
> my inexperience with git. I wanted to hit the reset button on git, and
> preserve the coding changes I made.
>
> I realize that there are more elegant ways to do this, but those methods
> required using tools
> that were not above my current skill level.
>
> Problems that I ran into:
> 1) I forgot to setup the commit hooks, and some of my commits did not pass
> that test.
> 2) I had the wrong e-mail address listed, so I wanted to fix that.
> 3) I did not understand the branching mechanisms of git very well, so I
> ended up with a bit of a mess.
> 5) My intermediate commits needed to be re-ordered to fit into a more
> logical commit structure.
>
> In order to do this, I took my non-logical branches, and created a complete
> patch set from them to disk, and then started re-importing the patches in a
> organized progression.
>
>
> Step #1
> ========================================
> mkdir ~/mypatches
> git checkout branch1
> git format-patch --outputdir ~/mypatches
> git checkout branch2
> git format-patch --outputdir ~/mypatches
> git checkout branch3
> git format-patch --outputdir ~/mypatches
>
> #Create patch sets, and then re-apply them as needed.
> git fetch origin
> git checkout master
> git rebase origin/master master
>
>
>
>
> git branch ITKv4.0A (branches off origin/master)
> git checkout ITKv4.0A
> ##=========
> % git apply --check --exclude CMakeLists.txt
> /Users/hjohnson/mypatches/0001-Removing-some-outdated-compiler-conditionals.patch
> % git apply --exclude CMakeLists.txt
> /Users/hjohnson/mypatches/0001-Removing-some-outdated-compiler-conditionals.patch
> ### The --exclude CMakeLists.txt was needed because that file was
> independantly updated on the master branch prior to patching, and made that
> patch unneeded.
> % git apply --check -v --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0003-Second-pass-at-removing-BORLAND-compiler-refs.patch
> % git apply -v --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0003-Second-pass-at-removing-BORLAND-compiler-refs.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0004-Removed-ITK_LEAN_AND_MEAN.patch
> % git apply
> /Users/hjohnson/mypatches/0004-Removed-ITK_LEAN_AND_MEAN.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0005-Unsigned-type-matching-for-ImageDimension.patch
> % git apply
> /Users/hjohnson/mypatches/0005-Unsigned-type-matching-for-ImageDimension.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0006-Removed-__sgi-IRIX-and-SCSL-references.patch
> % git apply
> /Users/hjohnson/mypatches/0006-Removed-__sgi-IRIX-and-SCSL-references.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0007-BUG-11075-Removal-of-SPROC-code.patch
> % git apply
> /Users/hjohnson/mypatches/0007-BUG-11075-Removal-of-SPROC-code.patch
> % git add -A; git commit
>
> ##ITKv4.0B (branches off ITKv4.0A)
> ##=========
> % git apply --check
> /Users/hjohnson/mypatches/0006-Remove-itkLegacyMacro-references.patch
> % git apply
> /Users/hjohnson/mypatches/0006-Remove-itkLegacyMacro-references.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0007-Removed-all-legacy-code.patch
> % git apply
> /Users/hjohnson/mypatches/0007-Removed-all-legacy-code.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0002-Removed-Brains2Mask-reader-writer.patch
> % git apply
> /Users/hjohnson/mypatches/0002-Removed-Brains2Mask-reader-writer.patch
> % git add -A; git commit
> % git apply --check
> /Users/hjohnson/mypatches/0008-Removed-dual-nature-of-Un-Oriented-Images.patch
> % git apply
> /Users/hjohnson/mypatches/0008-Removed-dual-nature-of-Un-Oriented-Images.patch
> % git add -A; git commit
> ## Extra whitespace at end of changed lines of code were causing commit
> warnings
> % git apply --check --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0009-rm-ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY.patch
> % git apply --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0009-rm-ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY.patch
> % git add -A; git commit
> % git apply --check --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0010-Removed-ITK_USE_DEPRECATED_FAST_MARCHING.patch
> % git apply --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0010-Removed-ITK_USE_DEPRECATED_FAST_MARCHING.patch
> % git add -A; git commit
> % git apply --check --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0010-Removed-ITK_USE_DEPRECATED_FAST_MARCHING.patch
> % git apply --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0010-Removed-ITK_USE_DEPRECATED_FAST_MARCHING.patch
> % git add -A; git commit
> % git apply --check --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0011-Removed-ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION.patch
> % git apply --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0011-Removed-ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION.patch
> % git add -A; git commit
> % git apply --check --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0012-Removed-ITK_USE_REGION_VALIDATION_IN_ITERATORS.patch
> % git apply --ignore-space-change --whitespace=fix
> /Users/hjohnson/mypatches/0012-Removed-ITK_USE_REGION_VALIDATION_IN_ITERATORS.patch
> % git add -A; git commit
>
> ====
> Cleanup -- remove old branches (from local repository, and from my personal
> gitHub forked repository).
>
> git push iowaITK :remove_sgi
> git push iowaITK :remove_sproc
> git push iowaITK :remove_borland
> git push iowaITK :ITK_LEGACY_REMOVE
> git push iowaITK :REMOVE_ORIENTED_IMAGE
> git push iowaITK ITKv4.0A
> git push iowaITK ITKv4.0B
>
>
>
> I hope this is useful to somebody.
>
> Hans
>
> --
> Hans J. Johnson, Ph.D.
> Assistant Professor
> 200 Hawkins Drive
> T205 BT, The University of Iowa
> Iowa City, IA 52242
>
> hans-johnson at uiowa.edu
> PHONE: 319 353 8587
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
>
--
==============================
Stephen R. Aylward, Ph.D.
Director of Medical Imaging Research
Kitware, Inc. - North Carolina Office
http://www.kitware.com
stephen.aylward (Skype)
(919) 969-6990 x300
More information about the Insight-developers
mailing list