This is the 6th day of my participation in Gwen Challenge. For details, see Gwen Challenge.
Problems git can solve
- Version control system
- CI/CD integration
- .
The characteristics of
- Excellent storage capability
- Extraordinary performance
- Open source
- Easy to back up
- Offline operation
- Workflow is easy to set up
- Distributed version control system
The difference between distributed and centralized
First, the centralized version control system, the version library is centrally stored in the central server, and when working, using their own computers, so we should first get the latest version from the central server, and then start working, finished work, and then push their own work to the central server. The central server is like a library. If you want to change a book, you have to borrow it from the library, then go home and change it yourself, and then put it back to the library. The biggest problem of centralized version control system is that it must be connected to the Internet to work. If it is ok in the LAN, the bandwidth is large enough and the speed is fast enough, but if it is slow on the Internet, it may take about 5 minutes to submit a 10M file. How does a distributed version control system differ from a centralized version control system? First of all, distributed version control systems have no “central server” at all. Everyone has a complete version library on their computer, so that when you work, you don’t need to be connected to the Internet, because the version library is on your own computer. Since everyone has a complete version library on their computer, how can multiple people collaborate? For example, if you change file A on your own computer, and your colleague changes file A on his computer, both of you just push your changes to each other, and each of you can see the other’s changes. A distributed version control system is much more secure than a centralized version control system, because everyone has a complete version library on their computer, so it doesn’t matter if someone’s computer breaks, just copy it from someone else. If the central server of a centralized version control system fails, everyone is out of business.
websiteThe git download
Follow the documentation process until you have successfully installed it and then click on the desktop window to view it (left below) or enter it in a command window
git --version
(right)
Configure the three functions of config
Git config --local # local git config --global # global git config --system # systemCopy the code
- View the config configuration
git confi g --list --local
git config --list --global
git confi g--list --system
Copy the code
Build a local Git repository
Two scenarios
- Incorporate existing project code into Git management
CD Project code folder git initCopy the code
- New projects are managed directly with Git
Git init your_porject # a folder with the same name as your project will be found in the current pathCopy the code
Commands and visualization tools
git add .
和git add -u
Add staging to any files in your current project that are not tracked by Gitgit add tools
Add the Tools folder to the staging areagit rm .
Deletes all traced files from the staging areagit rm readme.md
Delete the readme.md file from the staging areagit status
View the status of all files in the current project [staging and not added to staging]git commit -am 'type: message'
Add and submit all files for the current project to the staging areagit commit -m 'type: message'
Submit project files to staging area- Type: Specifies the type of modification to be made this time. The value must be any of the following:
- Feat: A new feature
- Fix: A bug fix
- Docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) Usually style changes such as whitespace, formatting, semicolons, etc.)
- Refactor: A code change that neither fixes A bug nor adds A feature
- Perf: A code change that Improves Performance
- Test: Adding missing or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation Changes to the build process or auxiliary tools and libraries such as documentation generation
- Message: Description of this commit
git reset --hard
Undo the last commit so that all records of the last commit are erased.git log
View all commit records
git log --oneline
View all submission records, withgit log
The difference is that the complete information of the record is not submitted, only the ID and description are displayed
git mv readme readme.md
Change the file namegit log -n4 --oneline
View the latest four submission records
git branch -v
View all branches under the current project
git checkout -b development
Create a newdevelopment
branchgit branch -av
View all branches of the current project
git log --all
View commit records for all branches of the current project (evolution history)
git log --graph
Presents the commit record as a tree list
git log --oneline -n7 --all --graph
Displays the last seven historical commits of all branches in a tree list
gitk
View the visual tools for Git management.
Interface plate analysisYou can also customize the view by using the view —-> New View in the upper left corner (or shift+F4).
git cat-file -t 70f497e2e1651f78c5189a
View the file type whose hash ID is 70f497e2E1651f78C5189a
git cat-file -p 70f497e2e1651f78c5189a
Look at the tree hash id within 76 b557b6cb8cf2545cff7b21ad4facee7f620a33 to change content in detail
git checkout -b fixBug 70f497e2e1651f78c51
Switch and create a fix Bug branch based on the hash ID 70f497e2e1651f78c51
.git directory decryption
Go to.git to view the files and folders
- HEAD holds a record of the current branch (pointing to the currently referenced branch)
- Config Local repository configuration information for the current project (including name, email, remote repository address)
- Refs Records the current warehouse label (milestone)
Relationships between commit, Tree, and blob objects
A commit will correspond to only one tree. This tree represents the snapshot of the current commit. This snapshot collection contains snapshots of all the files and folders of the commit. There will be only one BLOB