Revisiting Git thanks to Scott Chacon and O’Reilly
I just watched Scott Chacon’s excellent video introduction to basic Git functionality: http://video.linuxfoundation.org/video/1516. The audio was a bit tough to take, but it was free, and the content was so good that the audio didn’t bother me too much. There are many excellent resources on git-scm.org, home of Git, but for whatever reason I didn’t find anything as straightforward as what Scott has done. Admittedly, I probably didn’t try to hard, rather I just dove in and then became confused. The video introduces a bunch of concepts along with the commands, and that helped a lot in terms of orienatation to functionality.
To help me in the future, I made a list of the various commands I think I will be using once I get more into modifying the code of my projects that are now in repositories. Sorry for the brief explanations but perhaps the list can be useful to you as well (and I’m nervous about just leaving it on my hard drive and then forgetting where I put it, not that that ever happens to me
!).
git clone <git repo> – creates a git repo in current directory from the git repo id. If you clone, creates a remote called origin by default
git init – creates a new git repo in the current directory
git branch <new branch>
git checkout <branch> – switch to branch
git checkout -b <branch> – creates new branch and switches to it
git branch -v – shows last commit on each branch
gitk – visually shows branches
gitk –all
git commit -am ‘commit message here’ – does staging and committing in one shot
git add file – adds file to repo, or stages it if already there
git status – shows status of current repo
git log – shows log of commits
git diff – what changed between last commit and current
git add –p
git config –global <x> (for changing global values)
git config –list (for listing environment values)
git merge <branch> – Merges branch with current branch
git branch -d <branch> – removes a branch
git branch <new branch> <old branch> – creates a branch from old branch. You can use id from git log as old branch to identify branch point
git remote add <remote name> <remote code> – specifies a new remote location given by name and code
git push <remote name> <branch name> – pushes the branch to the remote location
git remote -v – lists the remotes for the repo
git fetch <origin> – gets the repo from the origin (remote) as a local branch (not override, like pull)
git log <branch> –not <other branch> – show a log of what is in branch but not in other branch
git log –stat <branch> –not <other branch> – shows log of specific lines in changes
git blame – lets you see who modified a line last
git bisect – awesome tool to help figure out where error introduced
git bisect good <commit point sha> – that point it was good
git bisect reset – resets to where you were before bisect process
git bisect bad – current point was bad
git bisect start – starts bisect by checking out middle commit, which you can test and then say good or bad
[Update: this wasn't part of the video, but a very useful command for people like me who rush to commit only after realizing I forgot to add a new file: git reset --soft HEAD^ - undoes the most recent commit, ready for me to add the right files and re-commit]
I also found this great resource from github.com: http://learn.github.com/
Moving back into Subversion
Over the past few days, I’ve been struggling to get a simple process for converting my Git repo into an SVN repo for upload/changes to Google Code. In spite of the artices I mentioned, it was a real struggle and I’m just not ready to spend the time to figure it all out — I give up, Google Code, I am going back to Subversion / Tortoise. Of course the latter is a very nice tool/environment, but it just works so well with Google Code that I can’t justify more time in trying to finagle Git and Google Code to cooperate. Also, my repo is pretty small, so maybe in a few months when I’ve forgotten the pain over the last few days, I’ll take another shot.
A few nice resources that helped me get started with Git and Google Code
I thought I would be pretty trendy and use Git for my Google Code project, though reading a bit through the Google Code docs tells me that SVN still reigns (some docs are old, though).
I originally had installed Cygwin on my Windows machine to use with Git, but I saw that msysgit makes the process easier, and of course I prefer easier. I am a bit concerned that when setting up Git, I chose the Windows options, and I don’t know how that will affect my downloads on non-Windows machines. A challenge for a later day.
I muddled through my first commit using the GUI provided with msysgit — very nice, lots of buttons to muck about with. It seems like I got it after one or two tries. I had created a new folder for my code and documentation, then git init to create the repository. A few minutes later, with the code in the folders, I made my first commit. Yay!
After I installed Git, I started watching Scott Chacon’s video tutorials. They gave me a whole new set of commands to play with, which I did through the Git Bash (shell), but comparing those commands with what I could see in the Git GUI, I got a better idea of what I was doing.
Emboldened by the appearance of success (though I still have my doubts), I decided to put my code on GitHub, so everyone who is waiting on the edge of their seat for my code can get access immediately. The GitHub documentation was pretty gentle, and helped me to commit my code there, only after a few tries. Through the Git Bash, I tried to create a remote origin and then push my stuff, but I kept getting GitHub to hang up on my process. Then I saw I had to give GitHub my public RSA key, which is probably why it kept hanging up on me. I could generate the key through Git Bash, then set it to the account. I’m not sure if I have to make a new key for each repository, but again, not my problem right now. A few more minutes later and the sweet smell of success!
Now I’m off to see how to synchronize GitHub with Google Code, or at least my local Git reposity with my Google Code repository. I found an article from last year about this, “Develop with Git on a Google Code Project“. Stay tuned…
[Update, 4PM]
Trying to follow the article above (Develop with Git on a…), I got frustrated for two reasons. First, because of the ambiguity I thought in the line:
First we perform the equivalent of a svn checkout. In an empty subdirectory, run:
$ git svn clone --username your-name -s https://your-project.googlecode.com/svn
Which username, the one for Google Code or the one for Git? It was pretty obviously the Google Code username, no problem. But “in an empty subdirectory”? Subdirectory of my Git repository? Any folder? Again, trying to remain calm, I figured a subdirectory of my repository. So I created one, then I changed into it. Finally, I was ready:
git svn clone --username myname https://flashsim-state-engine.googlecode.com/svn
Argh! Unexpected errors after it created the clone. I spent the next 45 minutes clearing things out (couldn’t find a Git command for removing a clone, so the ol’ rm seemed to work in the end). Nothing doing, I was almost ready to give up. Once it looked like it was working, it would ask for my password. Which password? I found the password on Google Code, Profile, Settings. Great! But I was still getting problems.
Time to search for more help on Google. I came across this article, by digitaleagle, regarding trying to get Git and Google Code to work together. I was very grateful the blogger had put a transcript of commands, so I could verify I was creating the right subdirectory.
Second issue I had–it then dawned on me that my code project is at “flashsim-state-engines”, not “flashsim-state-engine”. When I repeated the steps, voila!
So apparently I have my code now on Google Code and on GitHub. I see in Git GUI there is a place for a remote push — I wonder if I can hook it up right through the GUI (that would be nice). I’m not betting on it because it doesn’t seem to ask for all the info that was explained.
[Update, 4:45]
Seemed like it was uploading stuff, but on my Google Code page there is nothing. Bummer. I also saw this follow-up article to one of the previous articles, and it got the uploads started, but I don’t see anything in my Google Code page.
[Update, 5:30]
In a true Homer Simpson moment, I realized what the problem was. I had set my Google Code to use Mercurial versioning, since the comment there said it was for systems like Git. All this time making a subversion-compatible upload, I didn’t think I would have to set the versioning to Subversion. Needless to say, when I switched the option over to Subversion (in the Administer tab), I saw my code in all its glory. Yay!
Packaging my Hierarchical State Machine implementation for AS 3.0
It has been a long time in coming, but I am finally getting ready to release our alpha version of our hierarchical state machine for Flash ActionScript 3.0!
I will be writing blog entries over the next few weeks as I document my path to release. It hasn’t been hard to organize things, but I’ve certainly benefitted from finding blog posts about installing or doing this or that.
To begin the process, I created a Google Code project here. I had to choose a version control system for the code, so I chose Git. I was using Tortoise SVN for other projects, but I have heard good things about Git, and the idea of allowing others to fork projects without creating a whole new project was really intriguing to me. I have only had mild encounters with Flex, but I certainly believe that one of the great values in making a state machine implementation is going to be integrating the engine into Flex. However, I’m not the guy to do it well. Therefore, I’m trying to appeal to others who are more familiar to create a Flex fork, perhaps, or maybe haXe, and allow these other projects to influence where I might go with the AS3 implementation. The wonderful thing about not understanding all of this is that I am not limited to what the things actually do, only what I believe they should do
!
I have been developing the AS3 code in FlashDevelop, which is wonderful (needless to say). While of course I have Flash CS4, on my kick-ass iCore 7 Vista machine, the ActionScript editor inside Flash becomes painfully slow with only 1 or 2 pages of code, especially when I start typing things inside quotation marks. I’m now cleaning up the comments and generating the documentation via ASDoc. FlashDevelop has a command to initiate ASDoc, you just have to provide a few key pieces of information. For example, for AS 3, FlashDevelop requires you to specify where asdoc.exe resides. I have Flex Builder and the Flex SDK, so it was simple to navigate over to the sdk/ folder, find the latest version (3.3), and point to it inside the bin/ folder.
The Adobe Flex docs are pretty good for helping to understand the tags for ASDoc.
