Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of git and svn implementation?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the principle of git and svn implementation". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The principles of git and svn are different; git is a distributed version control system, svn is not, which is the core difference between git and svn non-distributed version control systems. Git stores content as metadata, while svn stores content as files.

This article operating environment: Windows10 system, Git2.30.0 version, Dell G3 computer.

Is the principle of git and svn the same?

Git is an open source distributed version control system for agile and efficient handling of any small or large project.

Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

Different from the commonly used version control tools such as CVS and Subversion, Git adopts the way of distributed version library and does not need to be supported by server-side software.

I. the difference between Git and SVN

GIT is not only a version control system, it is also a content management system (CMS), work management system and so on.

If you are a person with a background in using SVN, you need to make some thought changes to adapt to some of the concepts and features provided by GIT.

The difference between Git and SVN:

1. GIT is distributed, SVN is not: this is the core difference between GIT and other non-distributed version control systems, such as SVN,CVS.

2. GIT stores content as metadata, while SVN stores content by file: all resource control systems hide the meta-information of files in a folder such as .svn, .cvs, etc.

3. The GIT branch is different from the SVN branch: the branch is nothing special in SVN, just another directory in the version library.

4. GIT does not have a global version number, while SVN has: this is by far the biggest feature that GIT lacks compared to SVN.

5. The content integrity of GIT is better than that of SVN:GIT. SHA-1 hash algorithm is used for content storage. This ensures the integrity of the code content and reduces damage to the version library in the event of disk failures and network problems.

II. Git principles: Git work area, temporary storage area and version library

Basic concept

Let's first understand the concepts of Git workspace, staging area, and version library.

Workspace: the directory that you can see on your computer.

Temporary storage area: English is called stage, or index. It is generally stored in the index file (.git / index) under the ".git directory", so we sometimes call the temporary storage area an index.

Version library: the workspace has a hidden directory. Git, which is not a workspace, but a version library of Git.

In the figure, the left side is the workspace and the right side is the version library. The area marked "index" in the version library is the temporary storage area (stage, index), and the area marked "master" is the directory tree represented by the master branch.

In the figure, we can see that at this point "HEAD" is actually a "cursor" pointing to the master branch. So where HEAD appears in the command shown in the diagram, you can replace it with master.

The area identified by objects in the figure is the object library of Git, which is actually located in the ".git / objects" directory, which contains various objects and contents created.

When the "git add" command is executed on a file modified (or added) to the workspace, the directory tree of the staging area is updated, and the contents of the file modified (or added) by the workspace are written to a new object in the object library, and the ID of that object is recorded in the file index of the staging area.

When the commit operation (git commit) is performed, the directory tree of the staging area is written to the version library (object library), and the master branch will update accordingly. That is, the directory tree that master points to is the directory tree of the staging area at the time of submission.

When the "git reset HEAD" command is executed, the directory tree of the staging area is rewritten and replaced by the directory tree pointed to by the master branch, but the workspace is not affected.

When the "git rm-- cached" command is executed, the file is deleted directly from the staging area, and the workspace remains unchanged.

When executing "git checkout." Or the "git checkout--" command replaces the workspace files with all or specified files in the staging area. This operation is dangerous and clears changes in the workspace that have not been added to the staging area.

When executing "git checkout HEAD." Or the "git checkout HEAD" command replaces the staging area and the files in the workspace with all or part of the files in the master branch pointed to by HEAD. This command is also dangerous because it clears not only uncommitted changes in the workspace, but also uncommitted changes in the staging area.

This is the end of the content of "what is the principle of git and svn implementation". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report