Starting with Git and GitHub on Windows
My attempt at a very brief tutorial for starting with Git on Windows:
- Head over to github.com and create an account.
- Create a new repository next. Please remember that unless you pay for a github account, any repository you create will be PUBLIC. After creating the project, keep the page open so you can refer to “Next Steps” later.
- Download and install msysgit - look for a file in form of
Git-version-date.exewith the “Featured” tag. Use the installer’s defaults.
- Launch the “Git Bash” shell and setup your identity:
git config --global user.name "Your Name" git config --global user.email "email@example.com"
- Next create a SSH key pair for yourself using the following command:
ssh-keygen -C "firstname.lastname@example.org" -t rsa
- The file will be created at
c:\Users\username\.ssh\id_rsa.pub; copy the contents of this file and return to github. Click on “Account Settings” and then “SSH Public Keys.” Add your key here by pasting the content into the provided text box. Your local git installation and github accounts are now properly linked on this machine.
- Refer back to the “Next Steps” section mentioned earlier. Open “Git Bash” and follow the steps to create a new project and push it to GitHub. Your project is now ready. You can write some useful code!
If you prefer to avoid the command line for Git operations, launch the “Git GUI” and follow these steps when you want to make a commit and push:
- Press the “Rescan” button to see your changes
- Select the files you wish to commit from the list in the upper-left and choose “Commit” -> “Stage To Commit”
- Enter a commit message at the bottom of the screen and press “Commit.” The changes are now saved in the local repository.
- Click the “Push” button and examine the popup window. Note that the “Destination Repository” is remote and named “origin”; this refers to the repo at github. Click “Push” again to commit.
- Your changes are now committed to github. You can verify this by browsing to the project home page.
I hope others find this tutorial useful. A more detailed tutorial can be found courtesy of Kyle Cordes.