I want to pull from the github master full to update my current working directory. There is a file i've worked on called form.html which exists in my working directory and an older version on the github origin master branch.
git pull origin master
When pulling from the master Im asked to resolve conflicts. I do not want to resolve merge conflicts but instead want my file form.html from my local branch to completely replace the form.html on the origin master branch (remote)
Whats the best way to achieve this ? thanks
If you haven't committed your local file, you could (following the idea of "git pull keeping local changes"):
git stash
git pull
git stash pop
# if conflict on pop:
git checkout --theirs -- form.html
But if your file is committed, then see "Is it possible to exclude specific commits when doing a git merge?", and, with a .gitattributes, declare the proper merge:
form.html merge=ours
Assuming you've committed your form.html file...
After you've performed 'git pull origin master' and have conflicts, at that point you can easily resolve the conflicts based on your local version. Do the following after the pull:
git checkout --ours -- <files in conflict>
git add <files in conflict>
git commit -m 'resolved with --ours'
git push origin master
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