I would like to have an up to date copy (periodically) of the bitbucket repo on my server, but not sure which git commands I have to issue to avoid potential merge conflicts that can happen with pulls.
The only clean way I can think of is to clone to a tmp dir then copy/overwrite local repo.
But there must be a better way to achieve this?
You can also use git force clone to overwrite your history entirely. But be careful. This will destroy your local work.
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
Instead of cloning to a tmp dir and then replacing your local repository with that new clone, you can fetch from the remote and hard-reset your local:
git fetch origin master
git reset --hard origin/master
There won't be merge conflicts, as you're simply taking whatever is in origin/mater
.
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