Answer the question
In order to leave comments, you need to log in
How to delete a specific commit in git without deleting subsequent ones?
The essence of the problem is this. There are 250 commits, 241 need to be excluded (deleted) from the branch, it got into it as a merge. git reset --hard hash-comit doesn't work. rollback and commits above 241. Thank you all for the advice in advance;)
Answer the question
In order to leave comments, you need to log in
Here is a good algorithm for solving such problems:
Now and for the future
There are at least two options, correct from all sides - git revert <commit ID>. The commit will remain in the history, and another commit will be added to undo it.
The second option is to rewrite the history with git rebase -i, but if you have a merge there, the result will be bad.
in fact, posing the question "remove a commit" for those who use Git can hurt their ears, because all programmers know that code can be refactored indefinitely, so the command
not very popular with developers, they often use the command to undo the last commit
in your case, I think it's better to make a new commit, make those changes that you wanted to undo / add from the commit you care about, and in the comments to the new commit you can write why the changes were made and indicate the commit ID
git filter-branch --force (so that the directory is not removed from the hard drive)
git filter-branch --tree-filter "rm -rf PATH" HEAD
where PATH is the path to the file/folder
How do I remove a directory in Git?
https://help.github.com/en/articles/removing-sensi...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question