I have a few branches that mimic environments.
My ‘preview’ branch is where we stage our changes for review.
Anyways, it is way out of sync with development so I want to literally replace all the code in ‘preview’ with ‘development’.
Meaning, ‘preview’ still exists, but it now has the latest code from development. It is NOT merged, its literally a copy from development.
I’ve seen various solutions. I don’t "need" to keep the history and there are many developers workings off the branches, so I need something that they can just pull and get the updates, if possible.
Replace "preview" branch code with "development" code, while still retaining autonomy. Like throw away "preview" branch code and update it with "development" code. no merge, completely replace. All branches keep their independence. It is ok for preview to lose its history since I am starting over for it.
EDIT: preview has become a dumping ground, so I don’t want to merge and have all that crust in there. I want to start fresh with the latest greatest code from development.
I’m thinking of something like:
git checkout preview git reset --hard origin/development git push -f
But not sure how this will play with multiple developers.
git checkout development git merge -s ours preview git checkout preview git merge development
But I am worried its diverged too much.
git checkout development && git branch -D preview && git checkout development && git checkout -b preview
I just checked this and it worked for me — version 2.30.1
Answered By – hd1