Tuesday, May 18, 2021

Git Basics - Conflicting Merge / Resolution

git status -> on master, clean

git branch -> only '*master'

git checkout -b feature

mate feature.html

git commit -am "making changes to feature.html - change title"

git checkout master

mate feature.html -> change title and some area to make conflict, we chnage title on 'feature' branch

git commit -am "making changes to conflict"

take log to see

git log --online --graph --decorate --all

git branch -> *master , feature


you can get the diff

git diff master feature

to see visually

git difftool master feature

let's merge

git merge feature -> conflict, automatic merge failed

Note: your state is "Merging"


In your prompt

command prompt , you wil see as (master|MERGING)


if you look at file , you will see merge commentsor with conflicted merge content

mate feature.html

Note: HEAD points to 'master' here


git mergetool --> will invoke 'p4merge' tool

you can resolve conflicts here. Decide which will be accepted.

1. base version

2. Local 

3. Repo

Once resolve, commit

git commit -m "Done resolve feature.html"

Note: when you do "Commit" , you prompt wil change from  (master|MERGING) -> (master)

git status -> might show untracked files of origin files which contain merge conflict details


If so, add them to ignore file

mate .gitignore

*.orig

git add .gitignore

git commit -m "updating .gitignore file to exclude merge temp files"


you file may have entries like

----

.DS_Store

log/

*.orig


Done with the branch. let's delete

git branch -d feature

you  can see further in history

git log --online --graph --decorate -all

No comments:

Post a Comment