GitHub was easy to get up and running, but a few little quirks here and there got me.
- Already created your repository in GitHub
- Created an account in GitHub
- Set up git for Windows and using git-bash
Create an SSH key
This bit allows to you check out and commit code securely to github.
To check if it already exists, type in:
If it works, skip to the next step.
If you get "No such file or directory", then you'll have to create one.
ssh-keygen -t rsa -C "email@example.com"
The email doesn't have to be your github email.
Let GitHub know your public key
Copy everything from that file into the clipboard.
On the GitHub site click:
- Account Settings
- SSH Public Keys
- Add another public key
- Paste in everything from that file and give it a name of your computer (so you remember which computer can commit to the repo)
Test it out by typing (don't change it to your repo)
ssh -T firstname.lastname@example.org
Link your git to your github account
This step will link your github account to your commits.
On the site, go to:
- Account Settings (top menu)
- Account Settings (on the left menu)
- Copy your API token.
Back in the git-bash console:
git config --global github.user your_github_username
git config --global github.token 0123456789yourf0123456789token
Okay, this time you enter in your github username. Replace the token with your token accordingly.
Set up your user details
To ensure that your commits show up correctly with your name, make sure you set your author name. Otherwise your commits will show up with "Unknown" as author name like here.
git config --global user.name "Firstname Lastname"
git config --global user.email "email@example.com"
Again, this doesn't have to be your github email.
Your name should not match the github username either.
Getting the code
Finally eh? Don't worry, all of the stuff above you only need to do once.
Go to your project page and just below the description, make sure "SSH" is highlighted.
Go to your coding folder (the one that holds all of your projects) and type:
git clone <paste> [optional_checkout_name]
In my example it'd be:
git clone firstname.lastname@example.org:twig/Android-File-Dialog.git FileExplorer
That's because I wanted the directory name "FileExplorer" rather than "Android-File-Dialog" in my projects folder.
Make some changes to the code (like whitespaces or edit the readme) and type:
git add whatever_you_edited.txt
git commit -m"Test commit message"
That has committed the code locally.
To push it off to github, you'll have to type:
It'll take whatever commits you've made and dump it onto github.
Refresh your project page to check that:
- You've committed code properly (yes, it DOES show up straight away!)
- Your author name is showing up correctly.
- You haven't broken anything ;)