Using Git and GitHub on Ubuntu

From RobotForAll
Jump to: navigation, search

Install Git for Linux

$ sudo apt-get install git

Sign up GitHub account

https://github.com/join

Configure GitHub settings

$ git config --global user.name "username"
$ git config --global user.email "email address"

Create a local repository (test)

$ git init test

Create a test file in the local repository

$ cd test
$ gedit README.md

Add repository files to an index

$ git add README.md
$ git add --all (add all folders and files)

Commit changes made to the index

$ git commit -m "description message"

Create a repository on GitHub

https://github.com/new

Set the remote GitHub repository

$ git remote add origin https://github.com/username/test.git

Pushing files in local repository to GitHub

$ git push origin master

Clones a repository to your computer

$ git clone https://github.com/USERNAME/REPOSITORY.git

Fetches updates made to a remote repository

$ git fetch remotename

Merges updates made online with your local work

$ git merge remotename/branchname

Grabs online updates and merges them with your local work

$ git pull remotename branchname

References

Further readings