Introduction to version management tools git and svn

Version management tool

Introduction to Version Management Tools

  • Common version management tools
    • cvs(Concurrent Versions System)
    • vss(Visual SourceSafe)
    • svn commonly used version management tools
    • git popular version management tool (branch management is stronger than svn)
    • bitkeeper
    • hg
    • cc(ClearCase)

SVN

  • Common commands
    • checkout download code
    • update update local code code from server
    • add add files to the server
    • commit commits local changes to the server
    • showlog View version log

GIT

  • git init
    • Create a new repository (ie: git directory)
  • git add
    • git add * add all files to the repository
    • git add stc/ add a folder to the repository
    • .gitignore which files to ignore
      • Usually these files are ignored
        • *.config
        • *.creator.user
        • *.includes
        • *.files
        • *.bin
        • *.so
        • *.O
    • git add -A Add all files except .gitignore
  • git status
    • Display the status of the working directory and the staging area, and you will see the similarities and differences between the working area and the warehouse code
    • Do not display files that have been committed
  • git commit
    • git commit -m "add xxx" -m indicates additional code submission log information
  • git checkout
    • git checkout xxx checkout xxx directory
  • git log
    • View historical update information
    • You will see the unique number of the submission point, the submitter, the submission time, etc.
  • git revert
    • git revert + commit point unique number reverts to that commit point
      • The branch after that is not actually deleted, but the code at the commit point is resubmitted once.
  • git --help
    • git help
  • git branch
    • git branch 1.0 branch 1.0
      • Used to control the version of branches and milestones in the project, avoiding the clutter of commits
    • git branch -a View branch version
  • git checkout
    • git checkout 1.0 switches to branch 1.0
    • git checkout master switches back to trunk

git version completely rolled back

  • git checkout 1.0 switch branches first
  • git branch -d master delete the trunk code prompt (if it is an active branch, prompt)
    • git branch -D master delete branch without prompting
  • git branch master rebuilds the blank trunk

git multi-person cooperative development

single branch development

  • The project manager or administrator creates the code base on the server
    • git init test-project --bare
  • Zhang San clones the code from the server address xxx
    • git clone xxx
  • Zhang San writes code in the local test-project
    • You can git add and git commit to the local repository
  • After Zhang San finally wrote it, upload it to the server first
    • git push origin master:master
      • Upload the local master branch to the server's master branch, if the server does not have the branch, it will be created automatically
      • If Li Si submits code to the master after Zhang San, he must synchronize the local code with the master before submitting.
  • Li Sihou submits the code
    • git pull first synchronizes the code of the predecessor on the server
    • git push origin master:master and upload your own code

multi-branch development

  • Zhang San and Li Si established their own branches in the test-project and developed them respectively, and pushed them to their own branches.
  • Managers do branch merges
    • git merge origin/zhangsan ^o, ^s save changes
    • git merge origin/lisi merge lisi code into the current branch
  • merge conflict
    • Zhang San and Li Si modify the code in the same place at the same time, there will be conflicts
    • At this point, it is necessary to communicate whose code is kept and manually handle conflicts
  • Create a version branch when a milestone version is encountered
    • git branch v2.0
    • git push origin v2.0:v2.0
  • Zhang San and Li Si are revised on the milestone version
    • git merge origin/v2.0
  • shortcoming
    • After there are many branches, the management is chaotic
    • Note: The meaning of the branch should be clearly defined in the management

git other commands

  • Multiple warehouse storage
    • git remote add myserver http://xxx.com to add a warehouse server
    • git remote del myserver deletes a repository server myserver
  • delete server branch
    • git push origin :v2.0 will push an empty branch to v2.0 to overwrite

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324842870&siteId=291194637