Reference: https://www.liaoxuefeng.com/wiki/896043488029600
A), git use:
1. Create a repository (Resopsitory), equivalent to a directory with all the files are git management, each file will be modified with the deletion tracking and monitoring.
.git: Tracking Management Repository
Note: All versions of the controller can only track changes to the text, such as: .txt files, web pages, as well as program code, etc.
Two), git commands
git log: View commit log from the nearest to the farthest
git checkout: switching to the other branch
git checkout -: Modify command
git reset: fallback version, can also modify the temporary area retreated back to the work area
Note: * data will be submitted to the staging area to the master branch .git repository that is also capable of a fallback, ==== "can
但需要一条件:即:没有把本地版本库推送到远程
$ Git push origin master: the latest modification of the local branch pushed to the remote repository
C) the use of visualization tools to see git history
HEAD: The current version
HEAD ^: the previous version
The previous version: HEAD ^^
HEAD ~ 100: 100 in up version
git reset: fall back to the previous version
git work area and staging area
Workspace: Creating a repository
git init command to create the repository can become Git repository management
.git: git repository, execute git init command, it will automatically generate a file in the repository .git directory created
D), add a remote repository
step
- Create a local git repository
- Creating a warehouse in gitHub (the warehouse as a backup, others through the warehouse Collaboration)
- In order to run the local repository git repository associated gitHub
- Local content will be pushed to the remote repository
by $ git push origin master: the latest modification of the local branch pushed to github
Five), git code submission process
- By git add: placing the file in the staging area
- Use git commit: the staging area is placed in the branch file
File ------ "-------- staging area" branch
Note: You can add files to a plurality of staging area (Stage) , a one-time submission to the (master) on a branch
when creating the repository, will automatically create a unique master
Six), git branch management
HEDA: The current version -------> master (branch) ---------> latest submitted
Create a new branch dev
Increase dev pointer:
HEDA (the current version) -------> dev -------- "the latest submitted
master ----- "the latest submitted
Modify dev branch submit updates
When submitting modifications to the work area, dev branch move, pointing to the latest submission, master point unchanged,
At this point the modifications and submit the work area is a branch for dev
dev branch work is completed, the combined main branch master
master points to the latest submission of dev, HEAD points to master
HEAD ----> master ------> the latest submitted dev
Seven), git advantages:
Definition: Distributed Version Control System
- Networking also can not work
- Branch Management