Since the invention of The father of Linux, Git has been a powerful tool for many Internet enterprises to organize teams to write code. Therefore, as long as you enter the company, all of you are required to learn Git.

As a fresh graduate, Komatsu has left his graduate status. Although he has done some projects, he seldom uses Git, so he immediately joined the company. He has no idea about Git. It’s a great way to learn. Let’s learn. Enter the site and you will see the following table of contents

Based on article

git commit

This action commits the new version, as shown. Before the git commit

git commit
Copy the code

What does this master mean? C0,c1, C2, C3, no matter how many times you commit with Git commit… All belong to a branch called master, and the asterisk next to master refers to the current branch. In this way, it is possible to jump to different branches and convert different committed records from the same branch. If we want to go back to C1, but don’t want to undo C2, we can just command the master to point to C1, and if we have another branch, we can move the asterisk to another branch.

The above paragraph is important as a basis for understanding what follows

In other words, git is essentially a commit tree. You can commit and modify it over and over again, but you can find the previous commit record, and you can see who committed, what was committed, and when!

git branch

git branch newImage
Copy the code

After git branch newImage is executed, it is obvious that a new branch will appear. Guess where the new branch will appear?

git commit
Copy the code

git checkout <name>

Instead of typing Git commit, use Git checkout before doing so.

perform

git checkout newImage
git commit
Copy the code

perform

git checkout master
Copy the code

And then execute it again

git commit
Copy the code

git merge <name>

Merge two branches. Merge two branches. Whose name does the merge belong to? Git merge bugFix git merge bugFix git merge bugFix git merge bugFix git merge bugFix git merge bugFix

git merge bugFix
Copy the code

git checkout bugFix
git merge master
Copy the code

With the two merging, both branches have all the commit records, and the two new branches are finally merged.

summary

I tried to learn Git a few months ago, but both the blog post and the video often had some things that were not clear or caused ambiguity, only a true visualization can make people understand, kua to the author!

Let’s learn Git together, boy.