Git

I started on Git a couple years ago and it is addicting. Thank you Linus for writing it and freeing it for others to benefit (just like the Kernel).

I have a testing branch of code that I use in QA - that has all the changes in flight - so that could be 1-many things.. This makes piecemeal pull requests impossible since Github pull requests are computed against the branch.

What was shown to me was:

  • Master branch - keep as a pristine point to branch from.
  • For pull requests, cherry-pick just those changes into clean branch and submit that..
  • This is one way to work. I reserve the right to change my mind later on and declare this post utter rubbish.

Get the code

  git clone <ref>

Update said code

Get caught up before branching

 (master) % git remote add upstream <ref>
 (master) % git fetch upstream 
 (master) % git merge upstream/master

Stay up late coding!

Use testing branch for dev work

 (master) % git checkout -b testing

Work-work-work

 (testing) % # write code and unit tests

Branch for new commit

 (testing) % git checkout master
 (master) % git checkout -b ticket_18765342
 (ticket_18765342) % git cherry-pick <list of commit hashes for topic code>
 (ticket_18765342) % git push origin ticket_18765342

Post code merge

Now that the code is merged into master, fetch down all the changes, apply to the local master and your testing branch.

 (master) % git fetch upstream
 (master) % git merge upstream/master
 (master) % git checkout testing
 (testing) % git merge upstream/master

Nuke that topic branch

 (testing) % git branch -D ticket_18765342

Rinse and repeat

 (testing) % # write code and unit tests

Published on in