Use Git and GitHub

Thanks Bucky for his awesome git tutorial!! ---> thenewboston Git Toturial

Git commands

$ git init                    #create .git files

$ git add .                   #add all files
$ git add file                #add file
$ git rm file                 #delete file
$ git mv file1 folder/file2   #move file and rename it

$ git stauts                  #show changes
$ git diff                    #show difference between working copy and repository
$ git diff --staged           #show difference between staged area and repository

$ git commmit -m "comment"    #commit staging area to repository
$ git commit -am "comment"    #commit working copy to repository (use this carefully)

$ git log                     #show commit log
$ git log --author "name"     #show commit made by a specific author

$ git checkout xxx file       #take file from repository under commit xxx and overwrite working copy
                              # (get older version)
$ git reset HEAD file         #remove file from staging area, back to working copy

Three stages of Git

  • working copy: Files on your computer
  • staged area: Changes to be commited (Files that are on your computer and are not in the reopsitory)
  • repository: Files in the repository

GitHub

.gitignore: files to be ignored.

#push a git repository to github
#origin is the name for our remote repository locally
$ git remote add origin https://github.com/..../.git

#push all file in the foler to github
$ git push -u origin master         

Work with branches

  1. Create a new branch
  2. Edit file inside the branch
  3. New pull request
  4. Merge/close pull request (accept/refuse the changes to master branch)

watch, star, fork

  1. watch: follow this project
  2. star: book mark this project
  3. fork: copy this project to my account

Tip: Routine for a new post

$ rake new_post["title"]
$ #edit post
$ rake deploy
$ git add .
$ git commit -m "comment"
$ git push origin source:source  #exactly the same command

你可能感兴趣的:(Use Git and GitHub)