Git creates a new branch content and the current branch difference
Background: After creating a new branch, what is the difference between the content of the new branch and the current branch? With the following verification
scene 1
Current branch: dev, and the code is the latest
operation: create branch dev-2: git branch dev-2
difference: none
Scene 2
Current branch: dev, local code first and remote warehouse, not temporarily stored
Operation: create branch dev-2: git branch dev-2
difference: none , the new branch dev-2 synchronizes the local modification of dev
Scene 3
Current branch: dev, local code first and remote warehouse, temporary storage: git commit -a/git add file;git commit -m "x"
Operation: Create branch dev-2: git branch dev-2
Difference: Yes , the new branch dev-2 is consistent with the dev remote warehouse, and will not synchronize the local modification of dev
Summary :
- If the purpose of creating a branch is for independent development of dev and dev-2, be sure to temporarily store it before creating the branch dev-2;
- If the purpose of creating a branch is to submit a merge request (dev is protected and has no permissions), there is no need to temporarily store it before creating the branch dev-2;