I've been searching a lot for similar questions, but I'm not able to find a solution to my issue.
I want to fully overwrite a local branch with the content of a remote (other) branch, keeping my HEAD reference to the local branch.
This question How to replace local branch with remote branch entirely in Git? answers the first part, my local files would be overridden with the other branch content, but in git diff panel I wouldn't see what I'm changing from my current branch to the other.
Basically I would like to see on the left part of the diff panel the current branch file version,and on the right the other branch version. I could achieve the same result by deleting everything (manually) from the original folder, except from the .git
folder, and pasting everything (except from the other .git folder) from the other branch local folder.
I also tried some kind of merge command like (I'm working on main
branch and I want to take everything from the dev
branch)
git merge --no-commit --no-ff origin/dev
but of course this is not fully replacing files since I have to merge conflicts and there are some automatic merge operations on some files with additions on both sides.
I came up to this command
git reset --hard origin/dev
git reset --soft origin/main
which seems to be promising, since I can also see on the diff panel the main
branch files (that are not on dev
branch) like if I'm deleting them (which is what I want).
But if I compare the src
folders (local dev
branch with "overriden" main branch) I can see there is some difference between total file sizes (but I already checked that encoding is different between the two).
Can you tell me if this actually does what I want and if there is some downside on doing this?