Simple comparison between Git and SVN

In many cases, Git is much faster than SVN

SVN is centralized management, git is distributed management

Git stores content as metadata, while SVN stores content as files

4. SVN is clumsy in using branches, git can easily have an infinite number of branches

5. Git does not have a global version number, SVN does, which is by far the biggest feature git lacks compared to SVN

6. SVN must be networked to work properly. Git supports local version control

Git content integrity is better than SVN: Git content storage uses the SHA-1 hash algorithm. This ensures the integrity of the code content and reduces damage to the repository in the event of disk failures and network problems

SVN workflow and Git workflow comparison

  • svn checkout — git clone

SVN only downloads the code, and Git downloads it along with the repository

  • svn commit — git commit

SVN is committed to the server, git is committed to the local repository, need to use push to submit to the server

  • svn update — git pull

Download the latest modified code from the server

The biggest differences between distributed and centralized are: in distributed, there is a local repository of code that developers can submit locally; Centralized version control, on the other hand, only has a code repository on the server and can only be managed uniformly on the server

Git version backup/branch management

In Git, instead of copying code to solve the backup and open branches of Git directly tag, by controlling the head point, back and forth to any version

1. Version backup

1. Create a shared library

Create folder shareWeibo

After entering the folder, initialize the shared library

Git init – bare

2. The manager cloned the project and developed version 1.0, labeled it and uploaded the shared library

Create manager folder

Once inside the folder

Git clone Absolute path of the shared library

Enter the workspace and configure the name and email

Git config user. The name “manager”

Git config user. The email “[email protected]

The manager creates the file, modifies part of the code, commits the code, uploads it to the shared library, and completes v1.0

touch main.c

C :: Open main.c:: Write ABC

git add .

Git commit -m

git push

The manager labels this version and uploads the label to the shared library

Git tag-a v1.0-m

Git push origin v1.0

The manager continues to develop version 2.0…… And submit

git add .

Git commit -m

git push

  1. Bugs in the released version are fixed

Based on the previous steps, do the following

1. Cow clone project, create branches according to version 1.0 and fix bugs

Create the NIUDA folder

Once inside the folder

Git clone Absolute path of the shared library

Enter the workspace and configure the name and email

Git config user. The name “niuda”

Git config user. The email “[email protected]

Build a new branch v1.0fixbug based on the v1.0 version and switch to this branch

Git Checkout v1.0 -b v1.0fixbug:

Fix the bug and commit to the local version library

Note that the branch to which HEAD points is submitted -v1.0fixbug

git add .

Git commit -m

2. After fixing the bug, label V1.1 to back up the version and upload the shared library

Git tag-a v1.1-m

Git push origin v1.1

3. Upload the entire branch to the shared version library

Git push origin v1.0 fixbug

— At this point, the branch bug fix is finished, the manager will merge the branch —

1. The manager updates the code from the shared library to the local library

git pull

2. The manager checks the branches of the current server

git branch -r

 

3. After the manager switches to the Master branch, merge the V1.0 Fixbug branch

git checkout master

Git merge Origin /v1.0fixbug

 

4. The manager submits the merge to the shared library

git add .

Git commit -m

git push

 

5. After the merge is complete, you can delete branches of the shared library

Git branch -r -d Origin /v1.0fixbug

 

6. View the version label, end!!

git tag

Common Operations on the SVN

On your first day at work, download the company code onto your computer

svn checkout

 

Modifies an old file that already exists and submits it to the server

svn commit

 

Submit a new file to the server

svn add -> svn commit

 

Delete an old file that already exists and synchronize it to the server

svn delete -> svn commit

 

Update new code submitted by other colleagues to your own computer

svn update

 

I accidentally wrote a lot of things wrong and want to undo what I wrote (haven’t committed the changes to the server yet)

svn revert

 

Accidentally deleted the wrong file and tried to restore it (the deletion has not been committed to the server)

svn revert

 

I accidentally wrote a lot of things wrong and want to undo what I wrote (I have committed the changes to the server)

SVN update -r Indicates the version

 

Delete the wrong file by mistake and want to restore it (delete has been committed to the server)

SVN update -r Indicates the version