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
- Download Github Desktop for Windows
- Open
Github Shell
- Config global setting
git config --global user.name "Jerry Shao"
git config --global user.email "jerryshao@example.com"
- Generate your ssh key
ssh-keygen -t rsa -C "youremail@example.com"
- Copy your ssh key
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
- Create a new repository on github.
- Create your project folder
mkdir ~/Test
- Initialize as a git project
cd ~/Test
git init
Remote with github project
Copy your github repository address
cd ~/Test
git remote add origin "your github repo address"
Add & commit your project code
- Create a new file
echo "This is my first git project" >> READEME.MD
- Add this file into your project temp storage
git add .
- Commit this file
git commit -m "This is my first commit"
-m: message for this commit.
Push to github
git push origin master
Once you finish these steps, your first git project is ready to view on github.