In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the difference between using Git and SVN". In daily operation, I believe that many people have doubts about the difference between using Git and SVN. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "what is the difference between using Git and SVN?" Next, please follow the editor to study!
The difference between Git and SVN
Different storage methods
Git stores content as metadata, similar to KLV database, while SVN stores content by file (the new version of SVN has been changed to metadata storage)
Here, we give a simple example of using Git.
Cd .git / objects/df/ git cat-file-p df70460b4b4aece5915caf5c68d12f560a9de56e echo 'version1' > text.txt git hash-object-w text.txt
Use it in different ways
For example, we use the following figure to simulate the use of SVN.
We can use the following figure to simulate the use of Git.
Different management modes of versions
Git is a distributed version management system, while SVN is a remote centralized management system.
For example, we can use the following figure to represent the centralized management of SVN.
We can use the following figure to represent the distributed management of Git.
Summary of Git core commands
Git client installation
Official client download: https://git-scm.com/downloads
Other client downloads: https://tortoisegit.org/download/
Use of the Git command
(1) Clone to local based on remote warehouse
Git clone
(2) initialize the current directory to the git local repository
Git init
(3) create a project based on mvn template
Mvn archetype:generate
Add locally
(1) add the specified file to the temporary storage area
Git add
(2) add the specified directory to the temporary storage area
Git add
(3) add all
Git add-A
(4) remove the specified directory and subdirectories from the scratch area
Git rm-cached target-r
(5) add ignore configuration file .gitignore
Local submission
(1) submit to local warehouse
Git commit file-m 'submitted comment information'
(2) quickly submit to the local warehouse
Git commit-am 'Quick add and submit'
Branch management
(1) View the current branch
Git branch [- avv]
(2) create a new branch based on current branch
Git branch
(3) create a new branch based on submission
Git branch $git branch-d {dev}
(4) switch branches
Git checkout
(5) merge branches
Git merge
(6) conflict resolution
If the automatic merge fails due to a conflict, the status is in the mergeing state. Need to manually modify and resubmit (commit)
Remote warehouse management
(1) View remote configuration
Git remote [- v]
(2) add a remote address
Git remote add origin http:xxx.xxx
(3) Delete remote address
Git remote remove origin
(4) upload a new branch to the remote
Git push-set-upstream origin master
(5) Associate the local branch with the remote
Git branch-track-set-upstream-to=origin/test test
Tag management
(1) View the current
Git tag
(2) create branches
Git tag
(3) Delete branches
Git tag-d
Log management
(1) View all submission logs under the current branch
Git log
(2) View all submission logs under the current branch
Git log {branch}
(3) display log on a single line
Git log-oneline
(4) compare the differences between the two versions
Git log master..experiment
(5) display the submitted merge network in the form of a chart
Git log-- pretty=format:'%h% s'--graph
Basic principle of Git
GIT storage object (hashMap)
Git is a content addressable file system, its core part is a simple key-value database (key-value data store), you can insert anything into the database, it will return a hash key to retrieve the value.
(1) insert data into Git key-value library
Echo 'binghe' | git hash-object-w-- stdin 79362d07cf264f8078b489a47132afbc73f87b9a
(2) get the specified content based on the key
Git cat-file-p 79362d07cf264f8078b489a47132afbc73f87b9a
Based on this feature, Git saves the contents of the version of each file in the database, and when the version is to be rolled back, it is retrieved and replaced by one of the keys.
Git version write and rollback process
(1) find all git objects
Find .git / objects/-type f
(2) write to version 1
Echo 'version1' > README.MF; git hash-object-w README.MF
(3) write version 2
Echo 'version2' > README.MF; git hash-object-w README.MF
(4) write to version 3
Echo 'version3' > README.MF; git hash-object-w README.MF
(5) rollback the specified version
Git cat-file-p c11e96db44f7f3bc4c608aa7d7cd9ba4ab25066e > README.MF
So our common git add is actually inserting the modified content into the key-value library. When we execute git add README.MF, it is equivalent to executing git hash-object-w README.MF to write the file to the database.
We have solved the storage problem, but it can only store the content and not the file name. How do you know which content corresponds to which file if you want to roll back? Next let's take a look at the tree object, which solves the problem of file name storage.
Git tree object
Tree object solves the problem of file name, its purpose is to organize multiple file names together, which contains multiple file names and their corresponding references to Key and other tree objects, which can be understood as folders in the operating system, and a folder contains multiple files and other folders.
Each branch is associated with a tree object that stores all the file names and corresponding key under the current branch. You can view it with the following command
Git cat-file-p mastery ^ {tree}
Git submission object
A submission is a snapshot of the current version, which is saved through the submission object, which stores the following contents: a top-level tree object, the last submitted object, the submitter's user name and mailbox, the submission timestamp, and the submission comment.
$git cat-file-p b2395925b5f1c12bf8cb9602f05fc8d580311836 tree 002adb8152f7cd49f400a0480ef2d4c09b060c07 parent 8be903f5e1046b851117a21cdc3c80bdcaf97570 author binghe 1532959457 + 0800 committer binghe 1532959457 + 0800
To sum up, we can infer that a total of three objects are generated from the modification of a file to the submission:
A content object: stores the contents of the file
A tree object: the key that stores the file name and content object
A submit object: store the key of the tree object and submit comments.
Git reference
When we execute git branch {branchName}, we create a branch, which essentially creates a reference file based on the specified submission in git and saves it under .git\ refs\ heads\.
(1) create a branch
Git branch dev cat.git\ refs\ heads\ dev
There are three types of references to Git:
Branch reference
Remote branch reference
Label referenc
(2) query and compare the two versions
Git log master..experiment
(3) version submission History Network
Git log-- pretty=format:'%h% s'--graph
(4) View the branch tree
Git cat-file-p mastery ^ {tree} at this point, the study on "what is the difference between using Git and SVN" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.