I'm doing a pull origin some_branch and can see there are a lot of changes. Eventually I don't mind if their erase all mine.
How can I accept them all instead or using mergetool and merge files one by one?
Just:
git clone $url
Seriously! That's the best way.
You could do all sorts of git reset
and git branch
commands to move the refs, but the only purpose would be to keep your commits somewhere in your local repository for future reference. If that's the goal, just keep the whole repository as is, and re-clone the origin.
To accept all changes on just one branch, foo
:
git checkout foo
git fetch origin +refs/heads/foo:refs/remotes/origin/foo
git reset refs/remotes/origin/foo
foo
will now point at the same commit as foo
on origin
. If you want to blow away the files in your working directory, add --hard
to git reset
. If you want to merge first, replace fetch
with pull
.
You may have a bunch of dangling commits in your local repo, which git may clean-up someday, but for awhile you can still access them via the reflog.
Or:
git status | grep "both " | cut -f2 | cut -f11 -d" " | xargs git checkout --theirs
git status | grep "both " | cut -f2 | cut -f11 -d" " | xargs git add
which forces accepting all conflicting remote 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