Setting Up Git on Windows, Part 2

If you followed through the directives in Part 1 of this guide, you should now have a working version of Git on your Windows machine. Those with a *nix machine (including Macs) should already have Git installed. Those who have absolutely no idea how to use Git can either familiarize themselves with Chapter 2 of this book, or wait until my book gets published :)

In this part of the guide I will talk about setting up an SSH identity. Strictly speaking, you don't really need this to use Git with eithe GitHub or Bitbucket - you could push and pull over HTTPS instead of SSH by typing the password from your corresponding account every time. However, if your password is sufficiently long and secure (and it should be), this can get pretty tedious fairly quickly. That is where an SSH identity will come handy: it will teach GitHub and Bitbucket to recognize your computer when you try accessing a Git repository from it. The downsides are twofold: first, anyone with access to your computer will be able to interface with GitHub and Bitbucket repositories; second, if you routinely work on a number of computers you would need to go through this process on each of them.

Most of the steps are laid out straightforwardly in this guide from Bitbucket. You can skip Step 1 even though it is informative to get familiar with in case you don't have a clue what SSH is. I would pretty much encourage you to follow Steps 2 through 6 verbatim. (I would skip entering a passphrase in Step 3 unless you frequently share your computer with someone who you don't trust.) Step 7 assumes that you already have a local Git repository on your computer configured to use HTTPS. In case you are starting from scratch - i.e., when you have a set of files that you seek to put under version control - do the following:

  1. First, use the Git Bash shell to navigate to the directory with those
    files: cd /c/path/to/folderWithFiles
  2. Next, turn on Git in this folder: git init
  3. Finally, set up remote branch: git remote add origin ssh://

Once this is done, you should be interact with Bitbucket from Git Bash without any issues. To do the same with GitHub, you can use the same SSH identity. Simply open the file that you created previously with Notepad, copy its contents, and use the guidance in Step 4 of this guide to add the key to your account. This should be sufficient.

Congratulations, now you can freely use Git on Windows and interact with two major Git hosting services without any hassle! There is nothing really difficult about this process, but putting it all together can be less than straightforward for a beginner, and hopefully this two-part guide will make it easier.