Git Usage in Ubuntu


$ sudo apt-get install git

Sign Up on

Click here to sign up on

Create SSH Key

$ ssh-keygen -t rsa -C ""

id_rsa and will be created under /home/.ssh folder while id_ras is private key and is public key. Sign in github, and enter personal settings->SSH and GPG Keys. Click New SSH Key. Copy the content in and paste here.

Usage of git

Create repository

$ git init

Check the status of local repository

$ git status

Add changes to repository

$ git add file1name file2name ...

Add all changed files

$ git add .

Commit changes

$ git commit -m "comments come here"

Add remote repository

$ git remote add origin

Use the command

$ git remote -v

to check the remote repository that you just added.


$ git push -u origin master

while origin is the name of remote repository and master is the name of local repository.

When the remote repository is empty, add -u parameter in the command, otherwise not.


$ git push origin master


$ git clone

A new folder that has the same name as repository, like nameRepo here will be created and all the files will be cloned in this folder.

If you want to clone the repository to another folder, add a destination path after this command, like this

$ git clone destination

Note that no Chinese characters in repository path and do not use share folders between VMware and host in your repository path!!!


电子邮件地址不会被公开。 必填项已用*标注

13 − 2 =

5 + 5 =