Introduction to svn basic knowledge summary (code)

svn life cycle

  1. Create a repository:create

    The operation creates a new repository, which is used to store files, including the history of each modification.

  2. check out:checkout

    The operation creates a working copy from the repository as a developer's private workspace, where content can be modified and then submitted to the repository.

  3. renew:update

    The operation updates the repository to synchronize the working copy with the repository. Because the repository is shared by the entire team, when other people commit changes, your working copy will expire.

  4. To execute the changes:commit

    After checking out, you can add, edit, delete, rename, move files/directories and other change operations. When the commit operation is finally performed, corresponding changes are made to the repository.

  5. Review changes:status/diff

    When you make some modifications to the working copy, your working copy will be newer than the repository. It is a good habit to use the status/diff operation to review your modifications before the commit operation.

  6. Fix bugs:revert

    If you made a lot of changes to the working copy and didn't want those changes at the time, the revert operation can reset the changes to the working copy and restore it to its original state.

  7. To resolve conflicts:merge

    Conflicts may occur during merging, use the merge operation to merge. Because SVN merging is based on line units, as long as it is not the same line of modification, SVN will automatically merge. If it is the same line, SVN will prompt a conflict, and you need to manually confirm the modification and merge the code. Among them, the resolve operation can help find conflicts.

  8. Commit changes:commit (add comment)

    It is a good habit to add files/directories to the list of pending changes, and use the commit operation to update the changes from the working copy to the repository. Committing is to add comments.

specific

svn create

$ svnadmin create dir...

svn checkout operation

$ svn checkout svn://192.168.10.10/zinaer --username zinaer --password 123456

SVN conflict resolution

  1. View changes with the command
$ svn diff
Index: hello.txt
===================================================================
--- hello.txt   (revision 3)
+++ hello.txt   (working copy)
@@ -1 +1 @@
-hello world https://skm.zinaer.com
+hello world https://skm.zinaer.com 123
  1. try submitting directly
$ svn commit -m 'change first'
Sending        hello.txt
Transmitting file data .done
Committing transaction...
svn: E160028: Commit failed (details follow):
svn: E160028: File '/hello.txt' iAs out of date

You can see that the submission failed
3. Try to update and submit again

$ svn update
Updating '.':
C    hello.txt
Updated to revision 4.
Summary of conflicts:
  Text conflicts: 1

svn commit

  1. Add a file to the repository
$ cat README.md
# 简明 SVN 教程
  1. check status
$ svn status
?       README.md

? Indicates that README.md has not been added to version control.
3. add

$ svn add README.md
A       README.md    
  1. commit
$ svn commit -m 'add README.md'
Adding         README.md
Transmitting file data .done
Committing transaction...
Committed revision 6.

Submitted successfully... (feels a lot like git)

svn version rollback

  1. Modify a file at will
$ svn status
M       README.md
  1. revert (revert a single file)
$ svn revert README.md
Reverted 'README.md'
  1. revert -R (revert an entire directory)
$ svn revert -R zinaer
  1. revert -r (revert a committed revision)
$ svn merge -r 8:7 README.md

svn branch

The svn branch is essentially a copy of the trunk, but the branch has a version control function and is relatively independent from the trunk. Finally, the branch can be merged into the trunk, which is called a project.

  1. Create a branch locally
$ ls
branches/  tags/  trunk/

$ svn copy trunk/ branches/zhanbai
A         branches\zhanbai
  1. check status
$ svn status
A  +    branches\zhanbai
  1. Submit the new branch to the repository
 svn commit -m 'add zhanbai'
Adding         branches\zhanbai
Committing transaction...
Committed revision 9.
  1. Now we start developing in the zhanbai branch and create the index.html file
$ cd branches/zhanbai/

$ ls
hello.txt  index.html  README.md
  1. Add index.html to version control and submit it to the repository
$ svn status
?       index.html

$ svn add index.html
A         index.html

$ svn commit -m 'add index.html'
Adding         index.html
Transmitting file data .done
Committing transaction...
Committed revision 10.
  1. Switch to the trunk branch, update it, and then merge the zhanbai branch into the trunk
$ svn merge ../branches/zhanbai/
--- Merging r10 into '.':
A    index.html
--- Recording mergeinfo for merge of r10 into '.':
 G   .
  1. At this point, there is an index.html file in the trunk. Then, submit the trunk of the merge number to the repository
$ svn commit -m 'add index.html'
Adding         index.html
Committing transaction...
Committed revision 12.

svn tag

$ svn copy trunk/ tags/v1.0
A         tags\v1.0

A v1.0 directory will be created under the tags directory.

Then check the status and submit the tag to the repository.

$ svn status
A  +    tags\v1.0

$ svn commit -m 'add v1.0'
Adding         tags\v1.0
Committing transaction...
Committed revision 13.

commonly used

  1. svn log: used to display svn version, date, path
  2. svn diff : used to display row-level details of specific changes
  3. svn cat : Get a specific version of a file and display it on the screen
  4. svn list : Display a directory or version of existing files

Guess you like

Origin blog.csdn.net/qq_37768971/article/details/118493333