Introduction to Git & Github

What’s git


Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

What’s github


GitHub is a web-based Git repository hosting service. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.

How to set up your git environment


Mac OS

Open Terminal, and follow the steps below skip step 1~2.

Windows

  1. Download Github Desktop for Windows
  2. Open Github Shell
  3. Config global setting

    1
    2
    git config --global user.name "Jerry Shao"
    git config --global user.email "jerryshao@example.com"
  4. Generate your ssh key

    1
    ssh-keygen -t rsa -C "youremail@example.com"
  5. Copy your ssh key

    1
    2
    cd ~/.ssh
    cat id_rsa.pub


How to set up your github account


Once your github account has been created, go to Settings - SSH&GPG Keys page, paste your ssh key as a new record.


Create your first open-source project


Create & initialize your git project

  1. Create a new repository on github.

  2. Create your project folder

    1
    mkdir ~/Test
  3. Initialize as a git project

    1
    2
    cd ~/Test
    git init


Remote with github project

Copy your github repository address

1
2
cd ~/Test
git remote add origin "your github repo address"


Add & commit your project code

  1. Create a new file

    1
    echo "This is my first git project" >> READEME.MD
  2. Add this file into your project temp storage

    1
    git add .
  3. Commit this file

    1
    git commit -m "This is my first commit"

    -m: message for this commit.


Push to github

1
git push origin master

Once you finish these steps, your first git project is ready to view on github.