common commands are as follows:
$>git branch //View branch, there is a "*" in front of the current branch $>git branch BranchName //Create branch $>git checkout BranchName //Switch to BranchName branch $>git checkout -b BranchName //Create and switch to BranchName branch $>git merge BranchName //Merge the BranchName branch to the current branch $>git branch -d BranchName //delete branch
--------------
A simple use case:
when you have a new idea for the project, do this (create a new branch, then develop on the new branch, and finally Then merge it into the master branch.)
The specific steps are as follows:
1. Create a new branch and switch to this branch.
$>git branch -b new_branch //Create a new branch and switch to it.
②, start your work (various coding work);
blablabla...
③, add all changes to the stage
$>git add . //Add all changes to stage;
④. Submit the changes to the warehouse (the current branch new_branch)
$>git commit -m "My new idea, implemented on the branch" //Commit the changes to the repository (the current branch new_branch)
⑤, go back to the master branch
$>git checkout master //Go back to the master branch;
⑥, merge new_branch into the master branch
$>git merge new_branch //Merge new_branch to master branch.
⑦, you can delete the branch you created
$>git branch -d new_branch //You can delete the branch you created
----
Online exercise: Introduction to the basics of branch management Recommended branch strategy: Development must understand the branch strategy 2. List of questions 1. When a branch is merged, if there is a conflict, first resolve the conflict and then merge.
git status //View conflicts
2. When fixing bugs, we will fix them by creating a new bug branch, then merge them, and finally delete them;
when the work at hand is not completed, *git stash* the work site first, then fix the bugs, and after the repairs, * git stash pop*, back to work.
3.