Git introduction and what's different from SVN

Source: Internet
Author: User
Tags version control system

Git was developed by the famous Linux kernel (Kernel) developer Linustorvalds to facilitate the maintenance of Linux.

Git is a distributed version control system. As a distributed version control system, there is no concept of the main library in Git, and each copy of the library can be used independently, and any inconsistencies between the two libraries can be merged.

Using git under Windows, you can use Tortoisegit if you are unfamiliar with commands. Tortoisegit relies on msysgit.

In git, each local code base is a complete git system. With the Tortoisegit commit code (commit), it is simply committed to the local git repository. Once you have updated your local repository, you can push (push) to the remote repository and merge it into master or other branches.

GitHub is a Web site and also a project repository that enables multiple developers to easily collaborate on software development.

to install the git steps under Windows :

1. Download the latest tortoisegit-1.8.12.0-64bit.msi from http://download.tortoisegit.org/tgit/1.8.12.0/;

2. Download Git-1.9.4-preview20140929.exe from http://msysgit.github.io/;

3. Install Git-1.9.4-preview20140929.exe First, then install Tortoisegit-1.8.12.0-64bit.msi, press the default settings, restart the computer;

4. right mouse button-->tortoisegit-->settings-->general-->version, click Check Now, if display gitversion 1.9.4.msysgit.2 description configuration success;

5. If you download the relevant code from the Internet, choose Git clone, pop up the git clone dialog box, enter the address in the URL, if you need a user name and password, also pop-up dialog box to enter the user name and password, and then click OK, you can download the source code to local.

Some common uses of Tortoisegit :

1. Git clone ...: Clone a project code library to local (corresponding to SVN's checkout);

2. Git Create repository here ...: Git creates a new version here and builds a git project (Init);

3. Git sync ...: Used to synchronize two versions of the repository;

4. Tortoisegit-->pull: The remote version to the local repository;

5. Tortoisegit-->push: Push the local repository to the remote repository;

6. Git commit-> "Master" ...: submitted to the local repository, the pop-up dialog can be pushed to the remote repository after success.

the difference between git and svn :

1.      git is distributed, SVN is not, SVN is centralized: distributed mode, that is, each developer from the central repository/server check After the out code, it clones a repository on its own machine. In a place where you cannot connect to a network, you can still submit files, view historical version records, create project branches, and so on. Centralized version control systems have a single, centrally managed server that keeps revisions of all files, while the co-workers connect to the server through the client, removing the latest files or submitting updates. SVN features: (1). Each repository has a unique URL, each user obtains code and data from this address, and (2). Get updates to the code, and only connect to this unique repository to synchronize to get the latest data; (3). Submit must have a network connection (non-local repository); (4). Submission requires authorization , if there is no write permission, the commit fails; (5). Submission is not always successful. Unlike SVN, the Git record version history only cares about whether the overall file data has changed. git does not save variance data before and after the contents of the file. In a distributed version control system, the client does not just extract the latest version of the file snapshot, but instead completely mirrors the original code repository. Because Git keeps all the historical updates about the current project on the local disk, and most of the operations in git just need to access local files and resources without a network, it's fast to handle. Git features: (1). The repository for each clone in Git is equal. You can create your own repository from a clone of any repository, and your repository can be provided as a source to others; (2). Every fetch operation of Git is actually a full backup of the code warehouse at once, (3). The submission is completely done locally, without the authorization of others, your repository is your decision, and the submission will always succeed; (4). Even changes based on older versions can be submitted successfully, The commit creates a new branch based on the old version; (5). Git commits are not interrupted, merging occurs during pull and push, conflicts that cannot be resolved automatically prompt you to do it manually; (6). Git can also simulate centralized mode of work.

2. SVN's workspace and repository are completely separate, and Git's workspace and repository are the same: the SVN repository and workspace are stored under different paths, typically in different hosts. In an enterprise-class deployment of SVN, the repository on the server can only be accessed through protocols such as HTTPS,HTTP,SVN and not directly accessible to users. The SVN workspace is a snapshot of the repository in a historical state. Git's repository and workspace are in the same directory, and the workspace's root directory has a. git subdirectory. The directory called. Git is the repository itself, which is where Git stores metadata and object databases. This directory is very important, each time you clone a mirrored warehouse, the actual copy is the data in this directory. The Git repository can exist out of the workspace, but the workspace cannot be separated from the repository, where a repository clone file named. Git must be in the root directory of the workspace.

3. Git stores content as metadata, and SVN is by file: the. Git directory is a cloned version of the repository on your machine that has everything on the central repository, such as tags, branches, version records, and so on.

4. Version number: Git does not have a global version number, and SVN has. SVN each commit has a version number that is globally unique throughout the repository. Git's version number is further, and the version number is the only one in the world. The SVN version number is a sequential version number, and each new commit will have a version number of +1. Git uses this string as the version number for each commit, by calculating a SHA-1 hash of the contents of the file or the structure of the directory, resulting in a 40-bit hexadecimal string. All data stored in a GIT database is indexed with this hash value, not by file name. The advantage of using hash values for version numbers is that for a distributed version control system, there is no repetition of the version number that is formed after each commit. Another benefit is to ensure the integrity of the data, because the hash value is calculated based on the content or directory structure, so you can also determine whether the data content has been tampered with. Although the version number of git is discontinuous, there is a clue that each version has a corresponding parent version (one or two), which can form a complex commit chain.

5. Git's content integrity is better than Svn:git's content store uses the SHA-1 hashing algorithm, which ensures the integrity of the content of the code, ensuring that the repository is compromised in the face of disk failure and network problems.

6. Repository (repository): SVN can only have one designated central repository, when there is a problem with the central repository, all work members are paralyzed together until the repository is repaired or the new repository is set up. And git can have an unlimited repository, or each git is a repository, the difference is whether they have Active Directory. If something happens to the major repository, work members can still submit in their own local repository, waiting for the major repository to recover. Work members can also be submitted to other repositories.

7. Re-establish the starting point (rebase): In Git, if you want to put someone else's latest submission as the starting point of the current branch, just execute git rebase branch_name. This is different from merging (merge), where the merge will be considered up-to-date based on the time of the modification, and rebase will ask you to resolve the conflict where both sides have changed (confict).

8. System Archives: SVN will put a. svn in each directory, if you want to remove these. SVN is very tired (the latest version of SVN only has. svn in the root directory, subdirectories are not available). Git will have a. git directory at the beginning of the directory.

9. Git is a compressed transfer, SVN is a file transfer, so git network traffic is much less than SVN.

10. Partial Checkout (Checkout): SVN can check out the entire library to the workspace or check out a directory to the workspace. However, git can only check out all and does not support partial checkout by directory. In SVN, a working tree from the warehouse checkout, each sub-directory maintains its own. SVN directory, which records the modification of files in the directory and the corresponding relationship to the server-side repositories. There is no partial checkout of git, which is not to say that you can only view the files by cloning the entire library.

11. Update: In SVN, because there is only one central repository, so-called remote updates, known as SVN update, use this command to keep the workspace and repository synchronized. git uses git fetch and git pull to complete the remote update task. The fetch operation simply copies the object of the remote database to the local, and then updates the refs,git pull of the remotes head by adding the merge operation to the current branch on a git fetch basis.

12. Commit: In SVN, when you submit your code, it will be recorded directly to the central repository. When you find that your code has serious problems, you can't prevent it from happening. If the network is interrupted, you can't submit it at all. For SVN, all commit operations can be considered an update to the remote repository. You must use the commit command to synchronize files in the workspace (add), modify, delete (delete) operations to the repository. The Git commit is entirely part of the local repository activity. And you just "push" (git push) to the major repository. Git's "push" is actually doing "sync". In git, to include a file in version management, the first thing to do is to use git add to include the file in the stage (staging area, a middle state between the workcopy and the version of the repository head version), Only content that is updated to the stage will be committed at commit time. The git stage gives you a clear idea of what changes git will commit when you commit.

13. Branch (Branch): In SVN, the branch is a complete directory, and this directory has the complete actual file. And git, each working member can open a wireless branch in its own local repository. The GIT branch is fairly simple, you can quickly switch between several branches from the same working directory, and it's easy to find the branches that are not merged, so you can easily and quickly merge the files. The branch in Git is really just a file that contains the checksum of the object (40 character length SHA-1 hash), and a new branch is written to a file with 41 bytes (version number plus a newline character), which is naturally fast. The implementation of GIT is independent of project responsibility, and it can always be created and toggled within milliseconds. The GIT branch is completely isolated, and SVN does not. Git's milestones are read-only, and GIT is fully compliant with the space-time rule that history cannot change. The user cannot submit to a git milestone, otherwise the milestone is not a marker but a branch. SVN provides a feature switch that allows you to switch between different branches in the same working tree using switch. The command used by git to switch between branches is checkout.

14. Advantages and Disadvantages: SVN advantages: (1), easy to manage, logic clear, symbolic general people's thinking habits, (2), easy to manage, centralized server to ensure security, (3), code consistency is very high, (4), suitable for the development of a low number of projects. SVN shortcomings: (1), server pressure is too large, database capacity explosion, (2), if not connected to the server, basically can not work, cannot submit, restore, contrast and so on, (3), not suitable for open source development, but the general centralized management has a very clear authority management mechanism, can achieve hierarchical management, So as to solve the problem of large number of developers. Git advantages: (1), suitable for distributed development, emphasizing the individual, (2), the public server pressure and data volume are not too large, (3), fast, flexible, (4), any two developers can easily resolve the conflict, (5), offline work. Git cons: (1), the learning cycle is relatively long, (2), does not conform to conventional thinking, (3), code confidentiality is poor, once the developer has cloned the entire library can fully disclose all code and version information.

Reference documents:

1. http://www.vaikan.com/5-fundamental-differences-between-git-svn/

2. http://wenku.baidu.com/link?url=gc9leyhgnsmwhxz2r25ycnskmdaamew5p7yh6ems_1vpstxkble08qfc0ept2vo71qac_- Jblxfdc55vgkkujw-ius6_ljys2x2yhxr1hxs

Git introduction and what's different from SVN

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.