总的来说,主要有以下三点不同
GIT把内容按元数据方式存储类似k/v数据库,而SVN是按文件(新版svn已改成元数据存储)。
举个例子, 我们打开Git Bash ,演示一下 【元数据】的概念
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo
$ git init artisan # 初始化一个名为artisan的项目
Initialized empty Git repository in D:/opt/gitdemo/artisan/.git/
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo
$ cd artisan # 进入到artisan目录
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ ls
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ echo 'artisan test' > readme.mf # 写数据到 readme.mf文件
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ cat readme.mf # 查看写入的内容
artisan test
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ git hash-object -w readme.mf # 刷到git的存储里
warning: LF will be replaced by CRLF in readme.mf.
The file will have its original line endings in your working directory
ca30c25824b24fede390877fcddf0489eef76787
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ git cat-file -p ca30c25824b24fede390877fcddf0489eef76787 # 根据上一步返回的版本号查看提交的内容 (可以根据这个唯一串进行回滚)
artisan test
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ echo 'artisan test 2222' >> readme.mf # 新写入数据到文件
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ git hash-object -w readme.mf # 刷入git存储 ,返回的值与上一个不同
warning: LF will be replaced by CRLF in readme.mf.
The file will have its original line endings in your working directory
eef835b51d5b4d802765e88cfb19832c11de169b
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$ git cat-file -p eef835b51d5b4d802765e88cfb19832c11de169b # 查看
artisan test
artisan test 2222
artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/artisan (master)
$