First, view existing branches
View existing branches: git branch
commands;
As can be seen from the result, there is now only one branch master;
Second, create a branch
Create a branch: A per- git branch
name, you can create a branch, you can view the branch after the branch is created, the currently used branch will be displayed as green, preceded with "*", if not currently used, the display is white, and there is no "*" prefix;
Third, switch branches
Toggle Branch: git checkout
Branch name, after switching branches, the operation in the branch, file changes will not be reflected in the Master Branch, the main branch change, will be reflected in other branches;
About the main branch and other branches:
--Branch Editor: Existing two branch master branches, and the Branch1 branch just created, switch to Branch1 branch, create a file description_branch1.txt in Branch1;
--Other branch files do not affect the main branch: then switch back to master branch and find no Description_branch1.txt file, create a file description_master.txt;
--The main branch affects other branches: In the switch back to the Branch1 branch, a description_master.txt file is found;
Contrast process:
View the Project branch:
– Branch Results:
Switch to BRANCH1 branch:
– Switch results:
To view the files under the Branch1 branch:
– View file results:
Androidmanifest.xml ic_launcher-web.png Res
assets Libs src
bin proguard-project.txt
Gen
To create a file:
Add this file to the local cache:
Submit Local Cache: Note that this must be submitted, and if no cache is submitted, this file will appear in the main branch as well;
– Submit Results:
[Branch1 7f5785e] Add a description of Branch1
1 file changed, 0 insertions (+), 0 deletions (-)
To view the files under this branch:
– View file results:
Androidmanifest.xml Libs
assets proguard-project.txt
bin project.properties
<strong >description_branch1.txt</strong> Res
Gen src
Switch back to Main branch:
– Toggle Branch Results:
Switched to branch ' master '
To view the primary branch file:
– View file results: No files added in Branch1;
Androidmanifest.xml ic_launcher-web.png Res
assets Libs src
bin proguard-project.txt
Gen
Iv. Submission of Branches
Commit the Branch command: Submit the local branch to the GitHub;
V. Branch merging
Merge Branch command: After merging the branches, some of the files in the branch are also displayed in the main branch, equivalent to copying the files from the Branch1 branch into the master branch;
Merge results:
Updating f1bb97a. 7f5785e
Fast-forward
description_branch1.txt | 0
1 file changed, 0 insertions (+), 0 deletions (-)
Vi. Deleting branches
To delete a branch command:
Force Delete Branch Command: If the BRANCH1 branch has not been merged, Git is not allowed to delete the branch, and if you want to delete the branch, you can only use the following command to force the branch to be deleted:
Summarize
The above is the entire content of this article, I hope the content of this article for everyone's study or work can help, if there is doubt you can message exchange.