git using diagrams

Source: Internet
Author: User

Before use
    1. Install Git
    2. Configure name and email
git config--"Your Name" git config--"[email protected]" 
Working with local single-user workflows

    1. Initial git management repository
Git init
    1. Add files to a git repository
git add readme.txt
    1. Submit files to a git repository
"Upload Readme File"
Remote single-user workflow

    1. Clone a remote Git repository or associate a local repository
https://github.com/cizel/soft_backup 
Git remote add origin git@github.  Com:cizel/soft_backup.git 
    1. Add files to a git repository
git add readme.txt
    1. Submit files to a git repository
"Upload Readme File"
    1. Upload to a remote git repository
Push Origin Master
Multi-User Branch usage policy
    1. Basic syntax

      To view branches:git branch

      To create a branch:git branch <name>

      To switch branches:git checkout <name>

      Create + switch Branches:git checkout -b <name>

      Merge a branch to the current branch:git merge <name>

      To delete a branch:git branch -d <name>

    2. Use of Branches

GIT creates a develop branch command:

git checkout-b Develop Master

Commands to publish a develop branch to the master branch

  # Switch to Master branch git checkout Master # Develop branch to merge git merge--no-ff Develop 

tip:--no-ff

--no-ffpolicies that use quick Merge are not used

Use --no-ffA normal merge is performed and a new node is generated on the master branch. In order to ensure a clear version evolution, we would like to adopt this approach.

    1. Management policies for branches

First, the main branch master

First, the code base should have one, and only one main branch. All the official versions available to the user are published on this main branch.

Second, the development branch develop

The main branch is used only to distribute major versions, and daily development should be done on another branch. The branch we use for development is called develop.

Third, functional branches

The first is the functional branch, which is designed to develop a particular function that is separated from the develop branch. After the development is completed, it is to be merged into develop.

Iv. Pre-Release branch

The pre-release branch is separated from the develop branch and must be merged into the develop and master branches after the pre-release is finished. Its name can be used in the form of release-*.

Patch Bug Branch patch Bug branch is divided from the master branch. After patching is complete, merge into master and develop branches. Its name can be used in the form of fixbug-*.

Encounter problems See and compare
# tells you that a file has been modified git status#可以查看修改内容git diff
Version forward and backward
Log# View the command history to determine which version of Git to go back to in the future Reflog

Modify version

git reset--hard commit_id
Undo Commit
Reset--hard commit_idpush Origin HEAD--force
The difference between git revert and git reset
    1. Git revert is a new commit to roll back before Commit,git reset is to delete the specified commit directly.
    2. In the rollback of this operation, the effect is similar. However, there is a difference when you continue to merge old versions of the previous version later. Because git revert is a reverse commit "medium and" before the commit, so later merging old branch, cause this part of the change will not reappear, but git reset is to remove some commits on a certain branch, As a result, when the old branch is re-merge, these rollback commits should also be introduced.
    3. Git reset is to move head backwards, and git revert is head to move forward, but the new commit content and the content to revert is just the opposite, can offset the content to be revert.
The difference between git fetch and git pull
    1. git fetch: The equivalent of getting the latest version from remote to local, not automatically merge
    2. Git pull: the equivalent of getting the latest version from the remote and merge to the local, git fetch is equivalent to git fetching + git merge

git using diagrams

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.