Answer the question
In order to leave comments, you need to log in
Why can't I just rollback to a specific git commit?
To do this, I write git checkout commit, which gives me the type create a branch.
prntscr.com/bk847p
Found this solution.
Similar situation and solution.
Maybe someone who comes here from a search will find it useful.
To be honest, I didn’t want to understand the wilds of the terms “fasten”, “unstage”, and master the techniques of jumping through commits.
Indeed, when you do
git checkout
commit_id, further commits, as it turns out, stick to it outside of any branch, even if you checked out to your very last commit (for example, I expected that by returning to it, everything would really return to normal).
These commits hang, as it were, in an unnamed new branch, in a kind of inter-branch space. And of course, all attempts to push changes with the command
git push origin your_regular_branch
will not give you the expected result. Everything is fine with your branch, and with the changes too, it's just that all those commits that are made after your manipulations with rollbacks should be poured into your main branch.
The clearest and easiest way is to name the current state (the current chain of commits) as a new branch.
git checkout -b tempname
Then return to your home branch
git checkout your_regular_branch
and merge the changes from the created branch
git merge
tempname clarity of the method).
it remains only to delete the temporary branch, so as not to clog the rep.
git branch -d tempname
And you can push.
Answer the question
In order to leave comments, you need to log in
HEAD is now at - вы откатились. Но если будете комитить новые изменения, вам нужно будет создать новую ветку в этом месте, иначе куда комитить?
Чтобы создать ветку (сразу или позже пред коммитом) используйте команду git checkout -b
Вообще стоит почитать это https://git-scm.com/book/ru/v1 Там все расписано для начинающих.
я юзаю gut gui и там всё это довольно просто. (да да. Кидайте камни)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question