I sherzhil local branch (in which led the development) in the wizard branch and started it, later it turned out that you need to roll back the changes because there was an error in the logic of my code, because of what I need to roll back the branch back. How to do it? It is clear that you can create a commit bug that cancels, but I would like to know how to roll back the entire branch, while a lot of branches are constantly being added to the master branch.
- You can reset the local branch to the desired commit (mixed reset) further, asking your colleagues not to push them - and do force push. Your local copy will replace the branch in the repository - colleagues will pick up these changes and continue to work. If you already have something in the master, then you ask colleagues to pour in the branches again after your actions. - Sultanov
1 answer
- in the git program (unlike many other version control systems) a branch is not a “set of changes” ( commits ), but only a pointer to one specific change ( commit ).
- each change is “tightly bound” to the previous one (in the case of a merger, to more than one) change — it includes the hash sum of the ancestor.
- this set of related changes is called a change history .
- each copy ( clone ) of the repository ( repository ) contains the entire history of changes (yes, it can be “trimmed”, but this is a special case).
and if you want some kind of change (or series of changes) to “not exist in history at all”, this very story needs to be rewritten . not only in your local copy and in the repository of the repository that you use together with other developers, but also in each developer in his local copy .
therefore, the simplest (organizationally) option would be to “ revert ” unwanted changes.
You can roll them back one by one by listing the hash sums of changes:
$ git revert хэш1 хэш2 ... or you can roll back the “merge change” ( merge commit ) that was created when you “infused” your changes. if only two development branches were merged (as in the case you described), then:
$ git revert -m 1 хэш-изменения-слияния in order to subsequently apply these changes, it will be necessary to roll back this “rollback” already:
$ git revert хэш-изменения-с-откатом