Git learning (6): learning the diagram of merge

Ask yourself a few more whys every day, and you will always get unexpected results. The growth path of a rookie Xiaobai (copyer)

​ In recent work, I have come into contact with git rebase git cherry-picktwo merge instructions. git mergeI don't know what is the difference between them. It still feels like too little is known. Even, I git mergewas confused about using it. So, let’s continue to study today, git mergethis command.


topic

First, according to a picture, then follow the steps to type commands, and slowly understandmerge

insert image description here

The picture is a bit ugly, but the general meaning should be clear.

The process begins.

1. First create a folder managed by git

git init
2. Create master1.txt, then add commit
touch master1.txt   // 创建一个文件夹
git add .
git commit -m 'master c1'
3. Create master2.txt, then add commit
touch master1.txt   // 创建一个文件夹
git add .
git commit -m 'master c2'
4. master c2Create a branch on the basis of devand then create a file dev1.txtadd commit
git branch dev
git checkout dev

// 等价于
git checkout -b dev


touch dev1.txt
git add .
git commit -m 'dev c1'
5. Switch back to the master branch, continue to create master3.txt, and then add commit
git checkout master
touch master3.txt
git add .
git commit -m 'master c3'
6. The master branch merges with the dev branch

When the branches were merged here, I encountered a little problem, which I didn't pay attention to before.

Question one:

Not very familiar with Linux commands. As a result, I can't operate (the university wasted a few years), and then all kinds of Baidu.

insert image description here

Click ithe button to enter insertthe mode, and then fill in the commit informationmaster c4

insert image description here

Then click ESCEnter: :wqto save and exit.

That's it for the merge.

Question two:

解决git中(master|MERGING)
解决办法:
使用命令
git reset --hard head

https://blog.csdn.net/KaiSarH/article/details/102996400


View a diagram of a branch

git log --graph

insert image description here

Graphics for the introductory version:

git log --graph --pretty=format:"%h %s"

insert image description here


Summarize

The merge branch is merged, and a new commitmessage will be displayed. Added commitrecords.

// 新学习的两条命令
git log --graph
git log --graph --pretty=format:"%h %s"
// h: hash    s: message

Guess you like

Origin blog.csdn.net/James_xyf/article/details/120809220