S
S
sava2017-07-24 17:39:24
git
sava, 2017-07-24 17:39:24

How to roll back commits in a remote repository to a given one?

In the remote repository in the master branch there is such a set of commits
A - B - C - D It is
necessary to rollback for all clients to commit A, and the changes included in commit B must be reset to a separate branch. Commits C and D can be sacrificed.
What is the correct sequence of actions in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Moseychuk, 2017-07-24
@salihov

On one client:

git branch feature_branch B -- создать ветку на основе B
git checkout master
git reset --hard A -- сброс мастера на A
git push -f -- принудительное обновление удалённой ветки

Then on other clients:
git fetch --all  -- получить свежие данные с сервера
git checkout master
git reset --hard origin/master  -- сбросить локальную ветку на удалённую. Имя репозитория (origin) у клиента может быть другим

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question