I have two branches, email and staging. staging is the latest one and I no longer need the old changes in email branch, y
What you want is this (actually the exact inverse of the currently accepted answer):
git checkout email
git merge --strategy-option=theirs staging
What this does is:
email branch files will now be exactly the same as staging branchemail branch's history will be maintainedstaging branch's history will be added to email historyAs added value, if you don't want all of staging branch's history, you can use squash to summarize it into a single commit message.
git checkout email
git merge --squash --strategy-option=theirs staging
git commit -m "Single commit message for squash branch's history here'
So in summary, what this second version does is:
email branch files will now be exactly the same as staging branchemail branch's history will be maintainedemail branch's history. This commit will represent ALL the changes that took place in the staging branch