Reset remote git branch
I have two remote branches in git, master and test. master reflects whatever will be deployed to our production environment next. test is the same, but for our testing environment.
Because of stalled or scrapped projects test could, over time, theoretically accumulate a lot of commits not present in master. How do I avoid this?
- Using Julia packages from a Fork
- Git: how to push changes made to only certain files?
- Deployment with local Git submodules
- How to combine two commits in Git?
- Can I checkout github wikis like a git repository?
- using Notepad++ for git inside cygwin
I know one solution would be to delete my local and remote test branch. Then create a new one based on master and push that to remote. However this approach forces my colleagues and build/deploy systems to also delete their local branches before pulling a the new one.
One Solution collect form web for “Reset remote git branch”
Another approach, allowing to pull the
test branch is to reset the index of
test to the one of
master, not rewriting the history of
test, but adding a new commit which would reflect the same state as
That would however leave in
test history all the extra commits.
git checkout master git merge -s ours test # make master believe that everything from test has been merged to master up to this point. git checkout test git reset master -- . # reset the index content of test to the index of master git checkout # reset the working tree of test to its new index git commit -m "test reset to master" git merge master # should be trivial merge git push origin master git push origin test