The basic operation of git from VSS to SVN to git

Source: Internet
Author: User
Tags cos diff how to use git using git git mergetool

Source code control has been an important part of the software development process, from the original pure file backup to the use of tools for management. The Source Code control tool does more than simply manage the same version. From the current mainstream source code control tool is not difficult to find inside the branch, tag and other functions of the application of more and more, especially now most enterprises use of agile programming, combined with branch and tag functions really can be very good to do multi-version development, rapid iteration.

Thinking: There is no source code control for how quickly we can perform parallel development of multiple functions at the same time, based on a single piece of code.

Back to say I used in the industry of several source code control tools.

Vss

VSS (Visual Source salf), is a Microsoft-provided code management tool, as a member of Visual Studio, in the early development process is indeed able to ensure that the code is not modified by the developers, but also solve the remote development of collaborative code sharing management difficulties. But there are still some deficiencies, such as:

    • The file is basically locked in an exclusive situation. If A is modified, B has no way to modify it.
    • VSS supports only the Windows version, and the supported development tools only support the Microsoft Department.
    • Based on file storage, the server must share folders. Security is worth considering. Formerly used in the Intranet development environment.
    • Charges
Svn

SVN (Subversion), a source code control system. Apart from the most basic code management features, such as those provided by VSS, the biggest highlight is the branching, and the level of submission is based on the line of code. In other words, there is no need to have exclusive file development issues. For example, a code file that implements an interface can be modified by multiple developers at the same time. Whoever finishes first can commit, not wait until all the people have finished and then merge. For engineers who cannot use VSS, the advent of SVN is a complete boon, jumping directly from CVS to such a powerful tool.
To summarize, the advantages and disadvantages of SVN are as follows:

    • Advantage:
      • Code consistency is high.
      • Supports the submission of things.
      • Diff feature.
      • Branch,tag, convenient version management.
      • Easy to get started.
    • Disadvantage
      • It must be networked in order to read some data.
      • is not a distributed code base.
      • The disaster of the SVN server crash is huge.
Git

With the popularity of the Open source movement (Liunx developers), Git is so popular. Is it popular with the open source movement that is popular with git? This is thanks to the distributed nature of Git. Imagine, if all the world's Liunx enthusiasts are on several machines to develop and submit, this acid cool not to imagine. Or if the primary server crashes, then the rest of the developers are only crying.
The cool thing about Git is the following:

    • Each clone is a pull from the server to all content, including version information.
    • Locally, you can create your own branch locally, depending on your needs.
    • Any switch between branches.
    • Branch merging is possible on a single machine.
    • Cattle + plugin Plus. Git flow, a plugin provided by Vincent Driessen Branch model.

[Email protected]

A Successful Git branching model

How to use Git
    1. Installation
    2. $ Brew Install git

    3. Create a warehouse

    4. $ git init
    5. File operations

      Once you have a warehouse, you can add, commit, push, pull, and so on.

is
Tables
git add Add to Staging Area
Git add–interactive Interactive add
git apply Apply Patches
git am Apply Message Format Patches
Git annotate synonyms, equivalent to git blame
Git archive File Archive Packaging
Git bisect Two-point Search
Git blame FILE-by-line traceability
Git branch Branch Management
Git cat-file Repository Object Research Tools
Git checkout Check out to a workspace, switch, or create a branch
Git Cherry-pick Submit picking
Git citool Graphical commit, equivalent to git GUI commands
Git clean Clear the workspace does not track files
git clone Cloning a version library
Git commit Submit
git config Querying and modifying configurations
git describe Visually display submission IDs through milestones
Git diff Difference comparison
Git difftool Call the graphical diff comparison tool
git fetch Get the remote repository submission
Git format-patch Create a patch file in message format. See git AM command
git grep File Content Search Locator Tool
Git GUI Graphical tools based on TCL/TK, focusing on submissions and more
Git help Help
Git init Version Library initialization
Git init-db* Synonyms, equivalent to git init
git log Show Submission Log
git merge Branch Merge
Git mergetool Graphical conflict resolution
Git MV Renaming
Git pull Pull back the commit of the remote repository
git push Push to remote repository
Git rebase Branching variable Base
Git rebase–interactive Interactive branch-based transformation
Git reflog Branch and other reference change records management
Git remote Remote repository Management
Git repo-config* Synonyms, equivalent to git config
git reset Reset Change Branch "cursor" to point to
Git rev-parse Convert various reference representations to hashes, etc.
git revert Reverse Commit
git rm deleting files
Git show Display various types of objects
Git stage* Synonyms, equivalent to git add
Git stash Save and restore Progress
git status Show workspace file Status
git tag Milestone Management

.
.

Best Practice

It is recommended to use GitHub for a hands-on experiment. You can create your own repository on GitHub by registering the Git hub once with your mailbox.


2.png

Once created, we will get a repository address. With this address, we can do git exercises.


3.png
    • Clone the remote repository locally using Git clone.

      clone

5.png
    • Add some files
  "Hello Scott" -> "Hello"   //写了一个文件到Hello  git add Hello // 将Hello文件添加到暂存区。(Index)  git commit -m "this is my first file" // 提交到本地仓库 git push //推送本地仓库到远程仓库

6.png

Above, the file is pushed to the remote repository. Other engineers can pull the changed files to local if they perform pulling operations.


7.png
    • If another engineer modifies the file, it needs to be retrieved remotely.
       git pull  //拉取远端文件 git log //可以查看变更历史

A5b85bfd-764e-468f-81c4-0b727ba70428.png
    • Resolution of conflicts
      Conflicts are often caused by version inconsistencies. If agent a modifies the Hello file and submits it to the remote repository, and B modifies the Hello locally, it also wants to commit. Because the hello files of a and B are inconsistent, the conflict arises.

4eb9eb75-2ff9-4363-ad78-9e13d1415ea8.png

You only need git pull once. (Note: Git pull automatically merges, but usually the auto merge effect is not too good.) For example, A and B are modifying function A () {})
The conflict grew like this.


10.png

General manual resolution after the conflict, re-add, submit, push can be.


11.png

As described above, manual merge conflicts are more cumbersome. It is recommended to use the tool for GIT operations, and now the General Tools provide branch management, merging and other functions.
Recommended Sourcetree

Management of Branches

Many times you will have to develop multiple functions at the same time, the development task will be handed over to multiple engineers to develop, this time in the practice of git to create multiple branches. N Engineers branch-created from master or Dev branch.

git checkout -b NewFeature   // 分支建好后,会直接切换到该分支。git push --set-upstream origin NewFeature //与远程分支关联

Once development is complete, it needs to be merged into the master or dev branch.

  merge origin/NewFeature  // 将远程分支NewFeature与当前分支合并。

12.png
written in the last

The above diffusion from source code control to Git is just a start. Welcome everyone to advise.

The basic operation of git from VSS to SVN to git

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.