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-pick
two merge instructions. git merge
I don't know what is the difference between them. It still feels like too little is known. Even, I git merge
was confused about using it. So, let’s continue to study today, git merge
this command.
topic
First, according to a picture, then follow the steps to type commands, and slowly understandmerge
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 c2
Create a branch on the basis of dev
and then create a file dev1.txt
add 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.
Click i
the button to enter insert
the mode, and then fill in the commit informationmaster c4
Then click ESC
Enter: :wq
to 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
Graphics for the introductory version:
git log --graph --pretty=format:"%h %s"
Summarize
The merge branch is merged, and a new commit
message will be displayed. Added commit
records.
// 新学习的两条命令
git log --graph
git log --graph --pretty=format:"%h %s"
// h: hash s: message