Monday, March 29, 2010

git stash

git stash is really neat for working with different branches. Lets same I'm in one developer branch in the middle of something and I want to switch branches to save something. Well rather than having to make a temporary branch so I don't lose my work and I can use git stash.

If we make a change to a file and then try to change branches we get this

santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout master
error: You have local changes to 'Max_LCD.cpp'; cannot switch branches.

So what we do is run git stash, which tucks things away onto a local stack

santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git stash
Saved working directory and index state "WIP on dev: 0209cfa... changed MAX3421E to Max3421e for case sensitive compilers"
HEAD is now at 0209cfa changed MAX3421E to Max3421e for case sensitive compilers
(To restore them type "git stash apply")

santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout master
Switched to branch "master"
//inspect changes, now I need to switch back

santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout dev
Switched to branch "dev"

santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git stash pop
# On branch dev
# Changed but not updated:
# (use "git add ..." to update what will be committed)
#
# modified: Max_LCD.cpp
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# Max3421e.o
# Max_LCD.cpp~
# Max_LCD.o
# Usb.h~
# Usb.o
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (da0cd6de12e2128986ffdfe053f0c81cb5b264b3)

This makes a complicated situation much easier!

git simple upload branch

So I just got involved using git for the USB host shield. Really neat arduino project. Well its hosted on github, and while git seems awesome in its capabilities, it makes it more difficult to get started. I'm suppose to work in the dev branch, and I set up my ssh keys according to the website. And I have read/write priveleges, but it still took me an hour and a half to figure out how to download the branch, make a change and upload to the dev branch. Here is how you do it.


git clone git@github.com:felis/USB_Host_Shield.git
git checkout --track -b dev origin/dev
git commit -a
git push origin dev

So you clone the remote directory to your own, then you checkout the branch and give it a local name, in this case dev. Then you make commits, which are local. Then you push your commits to the server. the origin keyword keeps the url of where you got the branch, or something like that. You can also list the branches and find out which one you're on using git branch -a

Monday, March 22, 2010

Arduino Liquid Crystal initialization issues

I have been having some nasty issues with Liquid Crystal. Typical, starts up fine after a few reboots. Finally tracked down the issue. Need to increase delay after a clear signal has been sent from 2000 microseconds to 16000 microseconds. There is probably a middle ground somewhere as 16000 is a long time to send a clear command, however it fixes it for the moment.