Git branch management and workflow specification: refinement and demonstration of different scenarios

 

The first two articles introduced the basic concepts and specific specifications of git . This article will demonstrate different usage scenarios.

branch

branch naming
  • master branch name remains the same
  • develop branch name remains the same
  • feature/<branch name> feature branch
  • release/<branch name> branch to be launched
  • hotfix/<branch name> Online emergency fix branch
pull remote branch

git checkout -b <branch name> origin/<branch name> pull and link remote branch

Create new branch 

git checkout -b <branch name> creates a new branch and switches to the new branch

<!-- more -->

Submit Notes Specification

In the first line, briefly describe the content of the update;
leave a blank line;
after that, describe the content of the update in detail.

If it corresponds to the problem of jira, fill in the jira path: issue: http://jira.n.xiaomi.com/test1

Example

Fix bug, work order details page, work order record page, customer service avatar does not display
<empty line placeholder>
Cause: The code logic is not fully considered
jira: http://jira.n.xiaomi.com/test1

How to organize your commits and keep your commits clear

git commit --amend amend the most recent commit;
git rebase -i clean up the commit

  • edit, edit the remarks of a submission;
  • squash, merge the current commit forward until it is picked;
  • fixup is very similar to squash, the only difference is that fixup ignores the current commit information;

Again: if the commit has been submitted to the remote git repository, be sure not to reorganize and merge the commit.

for example

  1. Create a feature branch based on the develop branch named feature/feature1;

    git checkout -b feature/feature1

  2. Create a new file test.txt and submit;

    git commit -m ‘add test.txt file’

  3. Modify the file test.txt, add a line of content, submit;

    git commit -m ‘update text.txt file, append content: love vae music’

  4. It is found that the content added in the previous step is wrong, and I want to modify the content, but do not add a new commit and
    modify it to the correct content;

    git commit --amend; The modification window will pop up, modify the comment, if it does not change, press Enter directly;

  5. Submit 3 commits in a row, but want to merge into 1 commit;

  6. Use git log to determine the commit-id to be rebase;

  7. git rebase -i df87607d5dd24c0a73f23284e6988d6d32c0d3a4 shows the edit window

  8. Edit, modify as follows:

  9. The final result will only keep commit1:

How to join the development

Pull the develop branch from the remote:
git checkout -b <branch name> origin/<branch name> Pull and associate the remote branch

If you want to develop new features, create a feature branch based on the develop branch:
git checkout -b feature/feature1

If you want to fix an online emergency bug, create a hotfix branch based on the master branch:
git checkout -b hotfix/hotfix1

develop a feature

Create a feature branch based on the develop branch;

After the development is completed, organize your own commits and merge the meaningless commits;

Ready to go online in the next iteration, merge into the develop branch after finishing;

Not going to go online in the next iteration. After finishing, push the current branch to the remote git repository, and merge it into the develop branch when it is ready to go online:
git push origin feature/feature1:feature/feature1

Before merging into the develop branch, it must be tested locally!

Determine the version launch plan and launch

On the whole, there must be a clear launch plan to determine which functions are launched each time;

Only features confirmed to be launched in the next version can be merged into the develop branch;

Submit the test and fix the bugs reported by the test

Before submitting the test, make sure that all code changes have been submitted to the develop branch;

Based on the develop branch, create a release branch:
git checkout -b release/release1

Release the release/release1 branch to the test environment, and testers will test it;

Bugs found in the testing process are fixed and submitted directly in the release branch;

After the test is completed, confirm the launch, merge the code into the master branch and the develop branch, tag the release branch name, and delete the release branch:
git tag release.1.1.1
git branch -d release/release1

Fix online bugs

Based on the master branch, create a hotfix branch
git checkout -b hotfix/hotfix1

After the repair is complete, finish hotfix, merge the code into the master and develop branches;

Welcome to scan the QR code below and follow my personal WeChat public account~

 


love story

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326073668&siteId=291194637
Recommended