Quantcast
Channel: Will Anderson » windows
Viewing all articles
Browse latest Browse all 2

Configuring GitHub on Windows

$
0
0

If you’re a Windows developer like me, you’ve probably had trouble working with GitHub on Windows. Here’s what I did. Hopefully this will be helpful to you.

Getting Started

First you need to grab a copy of Git for Windows. Once you’ve downloaded the latest version, launch it and go through the license and location screens. Once you get to the “Select Components” screen, make sure both Context menu entries are selected. If you want, select the TrueType font option. That one shouldn’t really matter.

Jump ahead a few more frames and you’ll get to the SSH executable option. Choose “OpenSSH”, unless you have a compelling reason to use Plink.

Run through the rest of the frames, accepting the defaults. You now have Git installed on your machine, but we’re not quite done yet. GitHub uses public/private key encryption. This means you don’t commit with a username and password, like most SVN setups. Instead, you tell GitHub your public key, then use your private key to authenticate.

Generating a Public Key

If you don’t already have a public/private key pair, you need to generate one. You can do so with PuTTYgen. If you launch PuTTYgen, you should see something like this:

Click “Generate” and move your mouse around for a bit. In a few seconds you’ll have a key. Go ahead and copy the public key (the big text box). We’ll be entering that into GitHub, but don’t close PuTTYgen just yet. Back at GitHub, if you go to your account settings, there’s a page for “SSH Public Keys”. There you can click “Add a public key”, or “Add another public key” (if you already have one). Paste in the public key, give it a descriptive title, and save.

Great. Now GitHub knows your public key. This means you can use your private key to authenticate. Back to PuTTYgen. If you want to make your private key more secure, enter a passphrase. This makes it so, even if somebody gets your private key, they can’t use it to access GitHub unless they also know your passphrase. Once you’ve entered your passphrase, go to Conversions -> Export OpenSSH key.

You need to save your key in a very specific location. Go to your home directory (C:\Users\<username>\). Create a folder called “.ssh”. Now save the OpenSSH key to “id_rsa” inside that folder. So for example, if your username is “banana”, you should now have a file C:\Users\banana\.ssh\id_rsa that contains your private key. It’s also a good idea to save your public key, in case you need to use it for any other servers at some point. Click the “Save public key” button and save your public key in the same folder. Call it “id_rsa.pub”.

Clone a Repository From GitHub

You’re just about there. Go to your GitHub repository and select and copy the text in the textbox near the top of the page. Make sure SSH is selected.

Open up Git Bash. You should be able to find it in your start menu. “cd” to the directory where you plan on checking out your code. For example, if you want your code to be located in C:\programming\project then you want to “cd” to C:\programming.

Type out “git clone “, but don’t hit enter yet. Go to the top left corner of the Git Bash window and click. In the menu that pops up, select Edit -> Paste to paste the URL of your repository, but still don’t hit enter. Finally, type the name you want to call the project folder. In our example, you’d want something like this:

git clone git@github.com:CodeAwhile/wp-sendgrid.git project

Now you can hit enter :)

If you entered a passphrase for your private key, it will ask you for it, then if all goes well, your repository should be downloaded.

Some Sample Commands

This isn’t really a tutorial on Git commands, but here are a few to get you started:

See what files have changed:

git status

 

Add a file (new or modified, it doesn’t matter. You need to add it to commit it)

git add file.php

 

Add several files

git add *.php

 

Commit your changes locally (doesn’t put them on GitHub, just stores an update locally)

git commit -m "Your commit message here"

 

Push your changes up to GitHub

git push -u origin master

 

Pull down updates from GitHub

git pull

That’s about it. There’s more to Git (which I’m still learning about), but this should hopefully be enough to help you get started.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images