I fall in to this situation many times
1. I work on master branch and make some commits
2. Then i use git pull
3. Then i get auto merge fail , conflicting changes
Now suppose there were 5 files which were conflicting. I want to know
1. How can i overwrite those conflicting files with my files on my commit
2. How can i overwrite those with chnages from master
after i do git pull
When you fix your conflicted files and you are ready to merge, all you have to do is run git add and git commit to generate the merge commit. Once the commit was made , git push the changes to the branch. Reference article: Git merge.
Merge conflicts happen when you merge branches that have competing commits, and Git needs your help to decide which changes to incorporate in the final merge. Git can often resolve differences between branches and merge them automatically.
You can use
git checkout --theirs -- path/to/file.txt
to checkout what you fetched
git checkout --ours -- path/to/other/file.txt
to checkout what you had originally.
git diff --name-only --diff-filter=U | xargs git checkout --ours --
to use your version of all conflicted files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With