banner
RustyNail

RustyNail

coder. 【blog】https://rustynail.me 【nostr】wss://ts.relays.world/ wss://relays.world/nostr

Git Related

GIT#


Partition#

  • Workspace

The directory visible on the computer.

  • Staging Area

After git add, the modified files in the workspace will be added to the staging area.

  • Repository

After git commit, the files in the staging area will be packaged as a commit and placed in the repository.


Git Partition Legend#

1352126739_7909.jpg#

Basic Operations#

File Operations#
  • git add xxxxxx.java /folder
  • git commit -m -v
  • git stash pop
  • git reset head --hard

git stash/pop#

Used to temporarily save and restore modifications, can be used across branches

Note: Stash can only be executed before add! (i.e., before adding to the staging area)


commit message specification#

  • feat(module): New feature.
  • fix: Fix bugs, can be bugs discovered by QA or bugs discovered by developers themselves.
  • docs: Documentation.
  • style: Formatting (changes that do not affect the code execution).
  • refactor: Refactoring (code changes that are neither new features nor bug fixes).
  • perf: Optimization, such as performance improvement and experience enhancement.
  • test: Add tests.
  • chore: Changes to the build process or auxiliary tools.
  • revert: Roll back to the previous version.
  • merge: Code merging (conflict resolution, etc.).

commit message specification#

ss


Basic Operations#

Branch Operations#
  • git checkout -b branch
  • git merge branch
  • git rebase branch
  • git pull remote branch
  • git push remote branch

image
image


Merge Conflict#

<<<<<<< HEAD:index.html
<div id="footer">contact : [email protected]</div>
=======
<div id="footer">
 please contact us at [email protected]
</div>
>>>>>>> iss53:index.html

git merge --abort#


Characteristics of Merge#

Advantages#
  • Easy to use
  • Retains a record of each step
  • Retains the original record of the source branch
Disadvantages#
  • Retains a record of each step

Rebase#

Like merge, the main function is to merge branches, but there are many different details.

Move all modifications made to a branch to another branch, as if "replaying" them.


Rebase#

image

Execute git rebase master on the experiment branch to rebase the modifications in C4 onto C3.


Differences between Rebase and Merge#

1. Difficulty of use

Merge is easier to understand than rebase.

2. Different results in recording git operation history

Merge records all merge operations, while rebase only retains a serial commit record.


History after Merge#

微信图片_20210709232045.png


Too Many Merge Records#

image


History after Rebase#

微信图片_20210709232119.png


Branch Collaboration#

Git Work Flow#


Git Work Flow#

Categories#

  • Git Flow
  • GitHub Flow
  • GitLab Flow

Git Flow#

A collaboration model based on Git branch capabilities.

Branch Types#
  • Master Latest release version
  • Dev Latest development progress
  • Release Pre-release branch
  • HotFix Branch for emergency bug fixes
  • Feature Module development branch

General Process#

  1. Create the dev branch from master.
  2. Create various feature branches from dev and develop on the feature branches.
  3. The completed features will be merged into dev.
  4. After completing a stage of feature development, create a release branch for testing and other pre-release activities.
  5. Problems discovered during the release period will be fixed in the release branch and the fixes will be merged into dev.
  6. After passing the release test, merge into master and tag a version record in master.
  7. If a bug occurs online, create a hotfix branch from master to fix the issue and merge it into master and dev. [Special]

微信图片_20210710000300.png#

Github Flow#

Based on Git Flow, adds fork and Pull Request
微信图片_20210710003940.png


微信图片_20210710003940.png

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.