[Git] Create branch (branch) to test or add new features

Source: Internet
Author: User
Tags commit
This article contains two parts:1, create a new branch (branch) 2, back to a historical version of the project (history versions)
GIT Create a Project branch (branch) can solve the following two questions 1, test, need to change the code to change, 2, to add new features to the project, add new features of course, test; to create a branch to accomplish the above tasks without causing trouble to the project, it is absolutely wise.
Create a new branch one, view the current branch $ git branch-a Leslie (master) crawler $ git branch-a
Hard-mode
* Master Remotes/origin/master
The asterisk indicates the current branch, in the case above, currently in master
Two, create a new branch $ git branch easy-mode Leslie (master) crawler $ git Branch easy-mode Leslie (master) crawler $ git branch-a E Asy-mode
Hard-mode
* Master Remotes/origin/master

Three, switch branches $ git checkout easy-mode Leslie (master) crawler $ git checkout easy-mode switched to branch ' Easy-mode ' Leslie (ea Sy-mode) crawler $ git branch-a
* Easy-mode
Hard-mode
Master Remotes/origin/master
Then you can do whatever you like in this branch, so the changes will not affect master, you can change to Bug-free so far

Return to historical version one to see what the historical version of $ git log
The commit is followed by a commit ID, and below is the record of each commit, including the author, time, and comment, and we can decide which version of the history we want to return to based on comment. Then copy the Commit ID
Two, switch to the history version $ git checkout Commitid
The return of a long list of English, probably means that you are now in such a historical version, you can make some changes here, submit, you can discard in this state of the commit, will not affect the other branches.
If you want to create a new branch and keep your commit, you can execute the instructions git checkout-b new_branch_name
Third, create a branch in the historical version of Git Checkout-b history Leslie ((8a27a59 ...)) crawler $ git checkout-b histories switched to a new branch ' H Istory '
This way, you can return the project to a version of history, then do some testing, add features, and so on.
Finally, draw a picture of the difference between creating a new branch directly on master and going back to the historical version to create a new branch


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.