Miss sister with animation illustration git command, a look to understand!

Time:2020-8-18

Whether it is development, operation and maintenance, or testing, we all know the position of git in daily work. Therefore, it is also one of the necessary skills for us to learn. The official account also sent many git related articles before.

However, the brother of migrant workers often see the readers in the background. They say too many orders, but they don’t remember well. They don’t have to make complaints about time and so on. Yes, it’s really difficult to learn a technology, not to mention the technology update and iteration so fast

Therefore, for learning git technology, if you have an easy to read, easy to learn introductory materials. Not long ago, a little sister from abroad wrote such an article “CS visualized: useful git commands”. The author is Lydia Hallie, a little sister from British Columbia. In this article, she uses vivid animation to show developers the specific principles of merge, rebase, reset, revert, cherry pick and other common operations in Git commands in a more intuitive way.

Here are some examples to share:

1、git merge

Fast forward mode

Miss sister with animation illustration git command, a look to understand!

No fast forward mode

Miss sister with animation illustration git command, a look to understand!

The process of merging conflict repair is shown as follows:

Miss sister with animation illustration git command, a look to understand!

2、git rebase

The GIT rebase instruction copies all the latest commits of the current branch and then adds them to the specified branch commit record.

Miss sister with animation illustration git command, a look to understand!

Git rebase also provides six modes of operation:

  • Reword: modify the submitted information
  • Edit: modify this submission
  • Squash: merge the current commit into the previous commit
  • Fixup: merges the current commit into the previous commit without retaining the commit log message
  • Exec: execute a command on every commit that needs to be rebased
  • Drop: drop commit

Take drop as an example
Miss sister with animation illustration git command, a look to understand!

Take square as an example

Miss sister with animation illustration git command, a look to understand!

3、git reset

For example, the 9e78i submission added style.css File, 035cc submission added index.js Documents. With soft reset, we can undo the commit record, but keep the new one style.css And index.js Documents.

Miss sister with animation illustration git command, a look to understand!

Hard reset hard reset

Hard reset: the state of the current branch is restored to a specific commit directly without retaining the existing changes of the commit. It should be noted that hard reset will also remove all files in the working directory and staged files! As shown in the figure below:

Miss sister with animation illustration git command, a look to understand!

4、git revert

For example, we added the index.js Documents. It turns out that this file is not needed. You can then use the GIT convert ec5be instruction to restore the previous changes. As shown in the figure below:
Miss sister with animation illustration git command, a look to understand!

5、git cherry-pick

For example, the 76d12 commit on the dev branch added index.js File, we need to add the submitted change to the master branch, so we can use git cherry pick 76d12 to check out the modification of this record separately. As shown in the figure below:

Miss sister with animation illustration git command, a look to understand!

6、git fetch

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

Miss sister with animation illustration git command, a look to understand!
7、git pull

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

As shown in the figure below:

Miss sister with animation illustration git command, a look to understand!
8、git reflog

Git reflog is used to display the log of all operations performed! Including merge, reset, restore, that is to record all changes to the branch behavior.

Miss sister with animation illustration git command, a look to understand!

If, you don’t want to merge the origin / Master branch. You need to execute the GIT reflog command. The warehouse state before merging is located in the head @ {1}. Therefore, we can use the GIT reset instruction to point the head to head {1}.
Miss sister with animation illustration git command, a look to understand!

The above is the migrant workers brought to you today to share, if this article is helpful to you, please click to see and forward to share support, thank you. We study together and make progress together!!!

Original author: Lydia Hallie
Original text: https://dev.to/lydiahallie/cs…
Migrant workers through the translation of the original author plus some personal understanding, the copyright belongs to the original author, purely technical sharing, not for commercial purposes.

Recommended Today

Explain module, import and export in JavaScript

Author: Tania rascia Crazy technology house Original text:https://www.taniarascia.com/j… In the era of the Internet, websites are mainly developed with HTML and CSS. If you load JavaScript into a page, it usually provides effects and interactions in the form of small fragments. Generally, all JavaScript code is written in a file and loaded into a filescriptTag. […]