1. VCS system
Version control system, used for project storage, sharing, merging, history rollback, code tracking file history and other functions
Commonly used VCS software
Before CVS 2000
Before SVN 2010
Git 2010 to present
2. Commonly used concepts in Git
Working directory: It is a directory (folder) that saves all the files in the project
Temporary storage area: It is an area in memory for temporary storage of files in the project
Git repository: is a special directory that saves all files in the project and records of each modification
3. Git commonly used management commands
(1) Before using git for the first time, tell the git system who you are
git config --global user.name "custom user name"
git config --global user.email "user email"
(2) Create a Git warehouse and use the Git system to manage the current project
git init
The .git directory will be generated in the current directory, saving the history of all project files
(3) View the status of the current Git system
git status
(4) Add the specified file to the temporary storage area
git add filename
git add. Add all changed files to the temporary storage area
(5) Submit all files in the temporary storage area to the Git warehouse
git commit -m "commit description"
(6) View all submission logs in the Git repository
git log
git reflog View all commit logs, rollback records, etc..
(7) ignore files
Some files or directories do not need to be submitted to the warehouse and can be ignored
Use any editor to create a file .gitignore , and write the name of the file to be ignored into this file
(8) History regression
git reset --hard commit id
4. branch
For files separated without affecting the mainline development, there is only one master branch (master) by default in the Git system, and the final branch must be merged into the master branch
(1) Create a branch
git branch branch name
Copy the version of the current branch as a new branch
(2) View all branches
git branch
(3) switch branch
git checkout branch name
(4) merge branches
git merge branchname
(5) delete branch
git branch -d branch name delete merged branch
git branch -D branch name force delete branch, whether merged or not
5. Remote warehouse
Code Cloud: Domestic (I use Code Cloud gtiee)
GitHub: the world's largest
Create a remote warehouse first
Created in the remote warehouse
Push the local warehouse to the remote warehouse
git push warehouse address branch name
If you enter a wrong username or password Control Panel -> Credential Manager -> Windows Credentials Delete the corresponding account password |
Clone a remote warehouse to the local (no warehouse)
git clone warehouse address
Pull a branch from the remote warehouse to the local (existing warehouse)
git pull warehouse address branch name
force push
git push -f warehouse address master