Answer the question
In order to leave comments, you need to log in
How to properly remove the last commit that is running from the locale on github?
Hello everyone, I'm running my own git project. I made edits to the "branch name" branch, added it with git add .
, made a commit and pushed it all to the server via git push -u origin "название ветки"
. Then I saw that there is a jamb, and you need to cancel / delete the commit from the server (make changes to the locales and re-upload). Merge did not make branches.
How to delete this last commit in github now? And start editing it locally?
Answer the question
In order to leave comments, you need to log in
Two options from https://ohshitgit.com/en
1.
git reflog
# вы увидите список всего,
# что сделали в git, во всех ветках!
# у каждого элемента есть индекс [email protected]{индекс}
# найдите тот, перед которым всё сломалось
git reset [email protected]{index}
# волшебная машина времени
Use this to bring back things you accidentally deleted, or clean up what broke you, or recover from a bad merge, or just go back to when everything was working. I VERY OFTEN use reflog. Hats off to those who suggested adding this.
# найти хеш коммита, до которого нужно откатиться
git log
# используйте стрелочки, чтобы прокрутить историю
# сохраните хеш нужного коммита
git checkout [сохранённый хеш] -- путь/к/файлу
# старая версия файла окажется в вашем индексе
git commit -m "Ого, теперь не придётся копипастить, чтобы отменить изменения!"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question