Git Merge branch and Conflict – Step By Step

Git Merge branch joins two or more development history together. A merge conflict is an event that takes place when Git is unable to automatically resolve differences in code between two commits. Git can merge the changes automatically only if the commits are on different lines or branches.

Git Merge branch and Conflict

Step: Git branch Merge and Conflict

Step 1 :Create branch

witch administrator User command

# sudo su

Check created branch and if not created use “git branch branch1″ to create.

# git branch
# git branch branch1

Git Merge branch

Step 2: Git Merge branch create

# git checkout branch1

git checkout

Something add new code from branch1

# cat >newcode
This my new code in branch1

use those command to add or commit and check

# git add .
# git commit -m “code add from branch1”
# git log –oneline
# git show

Switch to branch for merge and check test git cord

# git checkout master
# cat test

use those command for merge and show the status

# git merge branch1
# git log –online
# cat test

step 3 : Conflict branch

check-in branch1 and open new git cord.
Note: create a new cord in branch1 and write something new .

# git checkout branch1
# cat >newcode
# git add .
# git commit -m “new git file in branch”
# git log –oneline

Conflict branch

Create same file in master git “newcode”

# git checkout master
# cat >newcode
# git add .
# git commit -m “new git file in master”
# git log –oneline

Conflict branch

use “git merge” command, you can see file has been conflicts

# git merge branch1

# ls
# vi newcode

After open please rectify the correct code in conflicts file

Conflict branch

# git log –oneline
# git add .
# git commit -m “new git file in master”
# git log –oneline

*******END*********

Install Git in Linux | Git log, Push, Pull

Install Git in Linux Git log, Push, Pull
  • Install Git
  • Set up Git
  • Create working file
  • Check git log
  • Create GitHub Account
  • Generate and copy 2FA password
  • Push and Pull working data to Github account for use world wide.


How to git branch Create, Delete, Rename

How to git branch Create, Delete, Rename
How to git branch Create, Delete, Rename
  • create a code and commit
  • Create new branch
  • Code add and commit in new branch
  • Rename branch
  • Delete branch
Rate this post
Sharing Is Caring:

2 thoughts on “Git Merge branch and Conflict – Step By Step”

Leave a Comment