# 1. Make a new branch, change new.txt and new-b.txt | |
$ git checkout -b changing-b | |
$ echo "line3 changing-b" >> new.txt | |
$ echo "line2 changing-b" >> new-b.txt | |
$ git commit -a -m "Added new line3, new-b line2 on branch." | |
# 2. Go back to master, change new-b.txt as well | |
$ git checkout master | |
$ echo "line2 master" >> new-b.txt | |
$ git commit -a -m "Added new.txt line2 on master." | |
# 3. Merge in changing-b branch, see the conflict | |
$ git merge changing-b | |
$ git status | |
# Notice that new.txt (no conflicts) is already staged. | |
# 4. See only the conflicts | |
$ git diff | |
# 5. Examine each version of new-b.txt | |
$ git show :1:new-b.txt # original version | |
$ git show :2:new-b.txt # master's version | |
$ git show :3:new-b.txt # changing-b's version | |
# 6. Resolve the conflicts, see what we changed | |
$ echo "line1" > new-b.txt | |
$ echo "line2 master and changing-b" >> new-b.txt | |
$ git diff | |
# 7. Commit, use the default commit message | |
$ git add new-b.txt | |
$ git commit | |
$ git l | |
$ git branch -d changing-b |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND