Dozens of animated pictures tell you how Git works



When trying to merge these branches, Git will show you where the conflicts occur. We can manually remove the changes we don't want to keep, save the changes, add the modified file again, and commit the changes.


reword: Modify the submission information;
edit: Modify this submission;
squash: merge the submission into the previous submission;
fixup: merge the submission into the previous submission , do not keep log messages for that commit;
exec: Run the command we want to rebase on each commit;
drop: Remove the commit.


When we don’t want the previously submitted modifications, we will Use this command. Maybe this is a WIP commit or maybe it's a commit that introduced a bug, in which case you need to perform a git reset.
git reset allows us to no longer use the files on the current desktop, allowing us to control where HEAD should point.
Soft reset
Soft reset will move HEAD to the specified commit (or compared to HEAD index of the commit) without removing changes added after that commit!
Suppose we don't want to keep commit 9e78i, which adds a style.css file, and we don't want to keep commit 035cc, which adds an index.js file. However, we do want to keep the newly added style.css and index.js files! This is a perfect use case for soft reset.

Sometimes we don’t want to Preserve changes introduced by a specific commit. Unlike a soft reset, we should never need to access them again. Git should simply reset the overall state directly to the state before a specific commit: this even includes changes you made in the working directory and on staging files.

Suppose ec5be adds an index.js file. But then we discovered that we no longer needed the changes introduced by this commit. Then restore the ec5be submission!


By executing git fetch on this remote branch, we can get these changes locally. This does not affect your local branch in any way: fetch simply downloads the new data.


git reflog is a very useful command that can display the log of all actions that have been performed. This includes merges, resets, reverts, basically any changes you make to your branch.

Suppose we don't actually need to merge the original branch. When we execute the git reflog command, we can see that the status of this repo was at HEAD@{1} before the merge. Then we perform a git reset and redirect HEAD to the location of HEAD@{1}.

The above is the detailed content of Dozens of animated pictures tell you how Git works. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

Which libraries in Go are developed by large companies or well-known open source projects? When programming in Go, developers often encounter some common needs, ...

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

When using sql.Open, why doesn’t the DSN report an error? In Go language, sql.Open...
