格 千格 KiloCell

Git Command Scatter List

Why do you master Git commands?

In the collaborative development of modern software, Git is not just a version control tool, but a bridge between developers. Although there are many good GUI clients (e.g. Sourcetree, Git Kraken), there are irreplaceable advantages to understanding and using command lines:

  • Extreme speed: Command line operations are usually much faster than the point menu, especially when dealing with complex transformations (rebase) or merging conflicts.
  • Environment is irrelevant: The Git command remains consistent, whether on the server SSH, CI/CD script or local terminal.
  • Getting to the bottom logic: Only by order can you really understand what is a temporary storage area, what is a reference and how Git stored data.

To address specific pains in development

Scenario one: I accidentally submitted the wrong document.
Use git reset --soft HEAD~1 You can withdraw your last submission, but keep your changes and you can re-college and then submit them. Use if you want to discard changes completely --hard Parameters.

Scenario 2: Half-developed, needing urgent repair on the line Bug.
Pass. git stash Press the currently unfinished work into the stack, toggle the branch fixes Bug before passing git stash pop Restoring the progress of work.

Scenario three: Want to merge a particular submission.
If you just need one fix on another branch, not the whole branch,git cherry-pick <commit-id> It's your salvation.

Git Best Practices Recommendations

  1. Step in, frequent: Each submission only fixes one problem or achieves one functional point, which makes rollback and code review extremely easy.
  2. - Write message: Follow <type>: <description> Format, for example feat: add login page, common type includes feat (new functionality), fix (rehabilitation), docs (documentation), style (format), refactor (reconstruction), test (test), chore (changes in build process or assistive tool).
  3. Use branch isolation for development: Never be in the direct. main Branch development. Create a new function or fix for each new function feature/ or fix/ Branch.
  4. Push--Pull: The whole family's gonna be in the middle of a long-distance warehouse. git pull --rebase The habit of keeping the linen clean of the presentation of history.

How do you use this stethoscope?

This tool is intended to be your second brain. You do not need to die to back all the complex parameters, but simply use the top search box to enter the keyword to find the command you need.Click on the card to copy it to the clipboard。 We have prepared all the instructions that you used to use from base configuration to advanced base, helping you to grow from Git to master of version management.

Command copied to clipboard