Miss Sister uses animated graphics to illustrate Git commands, you can understand them at a glance!

Whether it is development, operation and maintenance, or testing, everyone knows the status of Git in daily work. Therefore, it is also one of the must-have and necessary skills for everyone. Before the public account has also sent many git related articles:

These advanced usage of Git, use it if you like!
A quick look at Git commonly used commands, get the version control and follow
the Git tips summarized by ok Daniel, it is very good!
Master these 10 specifications and get Git easy!

However, the migrant workers often see readers in the background saying that there are too many commands and it is not easy to remember. Yeah, it ’s really difficult to learn a technology, not to mention that the technology is updated and iterated so fast now ...

So, for learning Git technology, if there is one that can be understood at a glance, it will be good to get started. Not long ago, a young lady abroad wrote an article "CS Visualized: Useful Git Commands". The author is the younger sister Lydia Hallie from British Columbia. In this article, she uses vivid animation to show developers the merge, rebase, reset, revert, cherry-pick in Git commands in a more intuitive way The specific principles of common Sao operations.

Here are some examples to share with you:

1 、 git merge

fast-forward mode

640.gif

no-fast-forward mode

640 (1).gif

The animation of the merge conflict repair process is as follows:

640 (2).gif

2 、 git rebase

The git rebase command will copy all the latest commits of the current branch, and then add these commits to the specified branch commit record.

640 (4).gif

git rebase also provides 6 operating modes:

  • reword: modify the submission information
  • edit: modify this submission
  • squash: merge the current submission into the previous submission
  • fixup: merge the current commit into the previous commit without keeping the commit log message
  • exec: execute a command on each commit that needs rebasing
  • drop: delete the submission

Take drop as an example:
640 (5).gif

Take squash as an example:

640 (7).gif

3、git reset

Take the following picture as an example: 9e78i submitted a style.css file, and 035cc submitted an index.js file. Using soft reset, we can undo the commit record, but keep the newly created style.css and index.js files.

640 (6).gif

Hard reset

During a hard reset: There is no need to keep the existing changes of the commit, and directly restore the state of the current branch to a specific commit. It should be noted that the hard reset will also remove all files in the current working directory and staged files! As shown below:

640 (8).gif

4、git revert

For example, we added the index.js file on ec5be. Later found that this file is not needed. Then you can use the git revert ec5be command to revert the previous changes. As shown below:
640 (9).gif

5、git cherry-pick

For example: 76d12 commit on dev branch added index.js file, we need to add this commit change to master branch, then we can use git cherry-pick 76d12 to check out this record modification separately. As shown below:

640 (10).gif

6、git fetch

Use the git fetch command to download the latest changes on the remote branch.

640 (11).gif
7、git pull

The git pull instruction actually does two things: git fetch and git merge.

As shown below:

640 (12).gif
8 、 git reflog

git reflog is used to display the log of all operations performed! Including merging, resetting, and restoring, that is, recording all changes to the branch.

640 (13).gif

If you don't want to merge the origin / master branch anymore. You need to execute the git reflog command. The warehouse state before the merge is located at HEAD @ {1}, so we use the git reset command to point the HEAD head to HEAD @ {1}
640 (14).gif

The above is the sharing that the migrant worker brother brought to everyone today. If this article is helpful to you, please click to watch and forward and share and support. Thank you all. We study together and make progress together! ! !

Author: Lydia Halle (Lydia Hallie)
Original: HTTPS: //dev.to/lydiahallie/cs ...
migrant workers brother by translation of the original plus some understanding from personal summary, belongs to original author , Is purely technology sharing, not for commercial purposes.

Guess you like

Origin www.cnblogs.com/youkanyouxiao/p/12731313.html