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
- Create a new branch
- Edit file inside the branch
- New pull request
- Merge/close pull request (accept/refuse the changes to master branch)
watch, star, fork
- watch: follow this project
- star: book mark this project
- 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
网友评论