How do I "re-parent" a clone of an Arduino Branch to new-extension ?

My knowledge of git (such as it is) is failing me.

My optiboot github repository is cloned from the Arduino "master" repository as per "case 2" here: http://code.google.com/p/arduino/wiki/GitandGithubGuideforArduinoDevelopment

However, Arduino "1" continued development in the "new-extension" branch rather than "master", so I wish to "re-parent" my clone to "new-extension" instead. "re-parent" is a term from a different Version Control System (probably from several.) It means that I want to make all the files that I haven't touched in my clone come-from/commit-to/etc the new branch (new-extension) instead of from "master", and all the files that I have touched (a small number) should get merged (automatically or manually) if they have actual changes. Future fetches should get new code from new-extension, and future commits should end up "pullable" by the Arduino new-extension branch...

How do I do that? What I tried seems to have gotten me copies of new-extension files, all ready for me to commit to my branch, which is NOT what I want...

(my local clone of the repository is no longer relevant; it can go away. I think this is my problem; I've done things to my local branch, but not to the githbub repository itself...)

The first thing you want to do, which will meet most of your requirements below is the following. It will get a copy of “new-extension” on your machine, and now it’s pullable, etc.

git checkout new-extension

Now you have to solve the problem of bringing your old work over. Three ways:

  • git merge master. Merges all of your changes neatly over from master. Also brings over everyone else’s changes. So if there is something in master you DON’T want, this is the wrong approach. But if everything in master is good, then this is the best way.
  • git cherry-pick . Select the commits you want to bring over. Since there are a small number, this should work well. If there are changes to the underlying code they affect you’ll have some work to do. Also takes a bit of work to find the changes you want.
  • git rebase. Rebase is way better if you have already isolated all your work into a personal branch. Then you can just rebase your personal branch off on top of new-extension, and Bob’s your uncle. Rebasing is the most complex, and worth plenty study before attempting.

Hmm. I don't HAVE any changes at the moment (or at least, the changes are easily managed.)

I think the problem now is ... how do I update my fork on github to be forked from the current version of Arduino? When I checkout new-extension, I get the new-extension files from the time when I originally created the fork...

how do I update my fork on github to be forked from the current version of Arduino?

This page may be of some help: http://help.github.com/fork-a-repo/

The normal approach is to merge upstream/new-extension into the new-extension branch on your machine, and then push them up to new-extension in your repo.

I don't HAVE any changes at the moment (or at least, the changes are easily managed.)

If you don't have any changes, then the easiest thing to do is delete your repository, and create a new one.