Git feature Branch

Source: Internet
Author: User

Feature Branch

In software development, there is always an endless amount of new features to add in.

When adding a new feature, you certainly don't want to mess up the main branch because of some experimental code, so every new feature is added, it's best to create a feature branch on top, complete, merge, and finally delete the feature branch.

Now you've got a new mission: Develop a new feature codenamed Vulcan, which is planned for the next generation of starship.

So ready to develop:

$ git checkout -b feature-vulcanSwitched to a new branch ‘feature-vulcan‘

After 5 minutes, the development is complete:

$ git add vulcan.py$ git status# On branch feature-vulcan# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## new file: vulcan.py#$ git commit -m "add feature vulcan"[feature-vulcan 756d4af] add feature vulcan 1 file changed, 2 insertions(+) create mode 100644 vulcan.py

Cut back dev , ready to merge:

$ git checkout dev

If everything goes well, the feature branch and the bug branch are similar, merged, and then deleted.

But

At this time, received orders from superiors, due to insufficient funds, the new function must be canceled!

In vain, however, this branch must be destroyed in situ:

$ git branch -d feature-vulcanerror: The branch ‘feature-vulcan‘ is not fully merged.If you are sure you want to delete it, run ‘git branch -D feature-vulcan‘.

Destroy failed. Git friendly reminder, feature-vulcan branch has not been merged, if deleted, will be lost changes, if you want to forcibly delete, you need to use the command git branch -D feature-vulcan .

Now we forcibly delete:

$ git branch -D feature-vulcanDeleted branch feature-vulcan (was 756d4af).

Finally delete success!


Summary

To develop a new feature, it is better to create a new branch;

If you want to discard a branch that has not been merged, you can remove it by git branch -D <name> force.

Git feature 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.