From XinCheJian
Jump to: navigation, search

This is a quick start for Github. If you want an explanation of the concepts, please go to Git.

What is Github?

Github is a website and service that hosts Git repositories. Public repositories can be created for free. Private repositories require users to pay for an account.

In order to use, you need to have an account.

Preparation (SSH Key)

In general, you will be working from your own computer.

  • You need a SSH key pair
  • SSH Key - Go here to learn more about how to create a pair.
  • Once you have created a pair, then you can connect your local computer with Github.

Go to Github and add your SSH key. ("Add SSH Key")

Working on a repository using Github's text editor

In this case, you will make edits directly in Github, without creating and cloning the repository on your local machine.

Working on your own local machine

Delete xinchejianbylaws.gif


  • Create an account
  • Linking SSH Keys

Actual First Time Workflow

  • Git Clone (or create)

Actual Second Time Workflow

  • Git Diff (to see unfinished work)
  • Git Pull
  • Git Checkout
  • (change your stuff)
  • Git Add (for changed and new files)
  • Git Rm (for removing)
  • Git Mv (for renaming)
  • Git Status (for seeing untracked files)
  • Git Commit (commits changes locally)
  • Git Push (puts your changes on the server)

Git Commands

This is random list of Git Commands.

Git Clone

git clone'''yourusername/yourrepository'''.git

Cloning your repository. Go get the repository.

Git Log

git log 

This shows what changes have taken place recently.

Git Checkout

git checkout (name of branch)

This switches your repository to the specific branch.

git checkout namename

This switches your repository to the specific branch called namename.

Git Branch

git branch

This will show you the different branches.

Git Status

 git status

This shows which files have changed or been added, but not committed to the repository.

Git Diff

 git diff 

This shows the differences of any changed files that have not been added.

Git Config

 git config --global push.default simple 

This configures git to do something. In this case, this is changing the global something.

Git Remote

 git remote -v   

This shows where the origin is.

git remote add origin 

This is example of how you would link to a specific Github repository.

Git Pull

git pull --all

This downloads the latest set of changes to your repository.

git pull origin master 

This downloads the code from the master branch.

Git Push

 git push 

This pushes changes the code back to the main repository.

git push -u origin master 

This would push your changes to the origin master branch.

Git Diff

git diff HEAD 

Shows the differences between the head and the working copy.

 git diff --staged 

Git Reset

git reset filefile 

This resets the file that you're working on.

Git Branch Clean Up

git branch clean_up

Oh jebus, don't use this. This throws away your changes.

Git Merge

git merge branchbranchname

This merges the changes into the branch.

See also

External Links