In this tutorial, you will learn how to use GitHub and work with others.
I would recommend you to signup for Gravatar first, so that you have a globally recognizable avatar that will be used to identify your Git commits. Navigate to https://en.gravatar.com/ for signup, use the same email as you configured in your local Git and upload your favorite photo as your avatar.
Github is now the world’s largest and most dynamic repository of open-source code. Let’s get started by navigating to http://www.github.com then signup for an account which you will use for hosting your source code for this tutorial and likely for future projects. And again, please use the same email address.
Before getting started, we need to generate some ssh keys so that GitHub knows that we have access rights as documented here.
$ ssh-keygen -t rsa -C "you@example.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): .ssh/id_rsa #Enter .ssh/id_rsa here Enter passphrase (empty for no passphrase): #Hit enter Enter same passphrase again: #Hit enter Your identification has been saved in .ssh/id_rsa. Your public key has been saved in .ssh/id_rsa.pub. The key fingerprint is: **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:** you@example.com The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | ** ** | | * * * | | * * ** | | * * **** | | **** ** | | ******** | +-----------------+
$ cd %HOME%
$ cd ~
$ cat .ssh/id_rsa.pub ssh-rsa AAA********************************************************************* ******************************************************************************** ******************************************************************************** *********************************************************End you@example.com
$ ssh -T git@github.com
You should see this if you have added the SSH key successfully:
Hi You! You've successfully authenticated, but GitHub does not provide shell access.
Congratulation, now you are ready to use GitHub!
If you haven’t create your project as a local Git repository, please follow the previous tutorial before starting this tutorial.
$ git remote add origin git@github.com:YOUR_USERNAME/YOUR_PROJECT.git $ git push -u origin master Counting objects: 9, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (9/9), 697 bytes | 0 bytes/s, done. Total 9 (delta 0), reused 0 (delta 0) To git@github.com:you/YOUR_PROJECT.git * [new branch] master -> master Branch master set up to track remote branch master from origin.
$ git clone https://github.com/YOUR_USERNAME/BUDDY_REPOSITORY.git
$ cd BUDDY_REPOSITORY $ git remote -v origin https://github.com/YOUR_USERNAME/BUDDY_REPOSITORY.git (fetch) origin https://github.com/YOUR_USERNAME/BUDDY_REPOSITORY.git (push)
$ git checkout -b feature123 $ echo "new feature" > feature123.txt $ git add feature123.txt $ git commit -m "Create feature123" [feature123 d0877fc] Create feature123 1 file changed, 1 insertion(+) create mode 100644 feature123.txt
$ git push origin feature123 Username for 'https://github.com': YOUR_USERNAME Password for 'https://YOUR_USERNAME@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 305 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/YOUR_USERNAME/BUDDY_REPOSITORY.git * [new branch] feature123 -> feature123