Table of contents
Introduction to Git
What is git, it is introduced on Wikipedia:
git是一个分布式的版本控制软件
分布式
It is relative to centralized, distributed means that each git library is a complete library.
The status of each library is equal, but generally a unified code management platform (server) is required for actual development. To simplify development, we only need to be consistent with the code of a specified remote git library to ensure that the code of the entire team is consistent.版本控制
It means that it will keep the code of each history. And we cancommands
restore the old code through some, it also supports分支
operations, and develop two different versions on the same code version. Tags can be created when a milestone is developedTAG
.- Git provides a series of
冲突解决
solutions that allow us to quickly resolve conflicts after code conflicts occur.- The ecology of git is also very complete
- There are a lot of great open source codes on github that we can learn from,
- Gitlab is a code management platform used by most companies in China for code management
One of the simplest GIT operation processes
Prerequisite: A git repository has been established
- create or modify a file
- Add the modification to the git cache, use
git add
the command- Put the modified content of the cache area
提交
to the version control, at this time usegit commit
the command- Push the submitted content to the remote git warehouse, at this time use
git push
the command
git workflow & commands
Configuration:
git config
Used to configure local user information and mark when submitting codegit cat-file
Used to view file type or contentLocal operation:
git init
Used to create a new git repositorygit add
Add changes to staging areagit checkout
Restore the files in the workspace and restore them to the temporary storage areagit commit
Submit the temporary storage area to adjust to HEAD (git library)git reset
Restore the staging area, restore from HEADgit status
View staging area statusgit log
View historical version recordsgit diff
Compare the differences between two filesgit branch
View branch informationgit rebase
rebase operationTemporary duty:
git stash
Temporarily store the current contentCollaborative development:
git clone
Clone the remote repositorygit push
Push the local library to the remote endgit fetch
Pull the content of the remote versiongit merge
Merge the differences between the two versionsgit pull
Pull the remote version content and merge the differences