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