I’ve been whining about wanting to learn GitHub for a while now so after they just released a shiny new Windows Graphical User Interface (GUI), I figured it was time to jump on board. Everyone I know who uses Git is a Mac/Ubuntu/Linux, and I’m a PC, so it’s been tricky to get someone to look over my shoulder and push through the initially steep learning curve. I’m also not comfortable with command line stuff, and prefer GUIs. The old me would go to GitHub to find code and then click the ZIP button while no one was looking. Not anymore. So, in case it helps anyone out there, here are the steps I took and my best explanation of what this whole Git/GitHub thing is anyway. It’s also a guide to myself to refer to in the future.
WTF is Git?
Git is a distributed version control system that’s free and open source. I’m still learning what that means too. But from what I gather, instead of doing my normal “versioning” as I iterate through writing Arduino or Processing code, or even Word documents, that usually look like this:
Git will allow me to work with one master copy, while allowing you to revert back to old ones if needed, and giving you a way to compare different versions (“diffs”). Git is local to your computer.
WTF is GitHub?
GitHub is a free, open source way to share code online. You can work on stuff locally and when you are ready for the world to see it, you can “push” the changes to GitHub. This enables collaboration with others on the same code or document, without having to email each other different versions back and forth (the way I used to do this). The next person can “pull” down your changes, work on it, then push it back. Also, if your laptop gets stuck in a downpour or something, you know your code is still alive and well online.
A while back I followed the instructions on this great post by Nate at Sparkfun. However, it’s a bit outdated now, and the whole workflow was still throwing me for a loop. It also left me with some questions – why Tortoise Git? Are there alternatives? etc. It is a great intro to how to get it done on Windows, and is written in beginner friendly language, and I do have a GitHub account now, so it is still recommended reading.
Then I recently went to the official Git site and downloaded the latest version (184.108.40.206 in my case) with one click on the front page. Most beginner guides I find, including the front page of this site, talk about how Git is better than other versioning systems. Well, I’ve never used one before, so comparisons aren’t helpful to me, and I won’t put you through that either.
Then I followed the set up guide on the GitHub site. After downloading, the next step was the link that says “… take a crash course.” So I did. Ignore all references to other version control systems. I got lost somewhere around staging area but I figured if I read everything I was supposed to it would make sense later.
Now back to the GitHub site. In the next section, Set Up Git, it immediately jumps into stuff you’re supposed to type into the command line. What they don’t say, is if you’re a PC like me, you have to navigate to the newly installed Git folder in your Start–>All Programs menu and select Git Bash to get a black screen to type in these new commands.
Follow the rest of the tutorial on that page to get set up. You only have to do this stuff once.
WTF is a Repository?
A repository or “repo” is just a fancy name for a folder that holds stuff, and part or all of it can be put under your ninja version tracking control. I just created some Processing code I want to upload yesterday that traces a path of a two degree of freedom robotic arm, so I’ll make a repo for that. This site, this site, this site, and most others will tell you how to add stuff to a repo using the command line. I hate the command line, so I looked for an alternative. THIS is where Tortoise Git comes in (now I get it Sparkfun, thanks!). I also found this guide which is a good walk through of the process. So follow the links to download the latest version of Tortoise Git, select all the defaults, then come back.
Okay now when you right click on any folder on your computer, you’ll see a few new options and a little turtle:
We have tell the Git system to pay attention to a particular folder. So, we’ll click the Git Create Repository here option. Click okay (leaving the box unchecked in the first window that pops up), then if you initialized Git in a folder that already had stuff in it like I did, click Proceed on the next window. All that did was add a little .git folder inside:
Download the Windows GUI
From this link. This new GUI claims to be the easiest way to use Git on Windows. Period. (We’ll see). Once you do this, you’ll see a new folder in your Start–>All Programs menu called GitHub, Inc. with a couple of icons inside. Click on the one that says GitHub.
Now if you go back and right click the folder again, and scroll down to TortoiseGit, you’ll see all kinds of options.
I want to add files to be tracked that I already have in the folder, so I go to Add
… and select the files I want to put under version tracking to also share on GitHub. This time, it’s just the P_2DOF_Arm.pde file. After selecting the file and clicking okay, you’ll see this screen
then click on Commit, and write a note in the box that pops up
Commit is Git talk for save to your local version tracking system. It’s a good idea to write little notes to yourself every time this happens so you can track progress.
NOW is when we get to use the shiny new Windows GUI (although the last few add/commit steps can also be done here). Open it up and drag the version tracked folder onto the main screen area, and you’ll see it added in gray
Now if you click on the right pointing arrow next to name of the folder you just dragged over, it will say open this repo. Do that and you’ll see all the content of the folder, and up top it will say push to github. Yeah! Let’s do that. When that’s done, you still have to hit publish to get the code onto GitHub. So do that. NOW you can use your browser to navigate to your GitHub account, and see the file in there!
Done and done. For now. I’ll probably write a follow up post clarifying how the various functions of the Windows GUI work once I play around with it a little more.