Install and apply git-svn in Ubuntu

Source: Internet
Author: User
Tags using git
Git is a distributed version management tool designed and implemented by LinusTorvalds, the founder of linux. For details about Git introduction and usage, see its official website. Here we will talk about how Git manages local code and synchronizes it with the existing SVN Central Library. 1. Install git-svn and include it in the Git installation Package by default. However, in Ubuntu, git-svn is an independent Package that requires additional installation of sudoapt-getinsta.

Git is a distributed version management tool designed and implemented by linux founder Linus Torvalds. For details about Git introduction and usage, see its official website.

Here we will talk about how Git manages local code and synchronizes it with the existing SVN Central Library.

1. Installation
Git-svn is included in the Git installation Package by default. However, in Ubuntu, git-svn is installed as an independent Package.
Sudo apt-get install git-svn
Environment Variable Configuration:
Configure/usr/lib/git-core to your PATH environment variable

2. Check out
Git-svn clone command to complete this operation
Git-svn clone http: // 192.168.18.80/Mar/trunk

Check-out step-by-step operation: the function is the same as the above steps
Create a local directory, for example, myproj
$ Mkdir myproj
$ Cd myproj

Initialize and obtain a version
$ Git svn init http: // 192.168.18.80/Mar/trunk
$ Git svn fetch-r xxxxx
Obtain a version. If no version is specified, it will be obtained based on the svn record level-1

3. Update
Git-svn rebase. Note that rebase is used instead of update.

4. View logs
Git-svn log
With the-v option, you can also provide detailed information about the files involved in each commit operation.

5. Submit
Synchronize local code to the Svn server. To synchronize data to the git server, run the git command
Git-svn dcommit
This command will submit all the changes you submitted to the local code library using git commit one by one to the svn library.
When the-n option is added, the command does not actually execute the commit to svn operation, but shows which local changes will be committed to the svn server.

Git-svn dcommit does not seem to be able to submit modifications to a local version separately. Instead, it submits all the differences from the svn center version libraries in batches.

6. Conflict Resolution
For example, the conflicting file is foo. c.
Use git-svn rebase to obtain the latest files on the svn server, resulting in a conflict,
However, the svn version information has been added to the local git Library (you can view it through git log)
Open foo. c and modify the code to solve the conflict;
Execute git rebase -- continue, and git prompts me:
You must edit all merge conflicts and then
Mark them as resolved using git add
Execute git add foo. c to notify git that the conflict has been resolved;
Run git rebase -- continue again, and the prompt "Applying: git v1" is displayed. At this time, the "git v1" version is successfully added to the local version library again. You can view it through git log;
Execute git-svn dcommit to synchronize the foo. c changes to the svn central database. This completes the resolution of the conflict.


Git is more intelligent and will prompt you to solve the problem, so pay attention to the prompt document when encountering the problem.

7. Set ignore files

To ignore some files, run the following command:

Git config -- global core. excludesfile ~ /. Gitignore

Then edit vi ~ /. Gitignore.

For example, if you need to ignore the vim temporary file, write:

. *. Swp

Related Article

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.