![]() ![]() Next time they push, they'll try and re-instate them as the local clones "see" that the origin does not have the objects (commits) that you have deleted. When it comes to editing that commit, execute git reset HEAD. ![]() This is what my latest commit looks like on a testrepo, but lets say I want the signs commit to be the latest commit. Mark the commit you want to split with the action 'edit'. How do you reset a Git repository to a certain commit This example will delete the commits made after the commit you want to reset to, and then weâll push it to origin. In fact, any commit range will do, as long as it contains that commit. ![]() It's important to note that if you have already pushed your code and others have pulled it, the above will not work as the commits will find their way back in there the next time someone who has your branch checked out does a push. Git applies the commits in the range you specify one-by-one, ignoring commits you have removed from the log. So, delete the lines that reference the commits you want to be rid of, save and close, and git will handle the rest (you may have to fix some conflicts depending on the nature of the commit and the revert you're trying to delete). at 18:06 22 Chris, the answer with git rebase -i HEAD10 does address the question, as it does let you arbitrarily pick commits to delete. The key bit for you is If you remove a line here THAT COMMIT WILL BE LOST. # Note that empty commits are commented out # However, if you remove everything, the rebase will be aborted. Also, just as a quick reminder, git reset -hard will move the HEAD pointer back to the commit hash that was given, the Stage Index and the Working Directory will be reset back to the way they were at that commit, and all commits after the commit that was given will be dropped from the commit history.# If you remove a line here THAT COMMIT WILL BE LOST. # These lines can be re-ordered they are executed from top to bottom. # x, exec = run command (the rest of the line) using shell # f, fixup = like "squash", but discard this commit's log message # s, squash = use commit, but meld into previous commit # e, edit = use commit, but stop for amending Use git revert to revert back to a previous commit.Use Push to update it to a remote server (Like github). # r, reword = use commit, but edit the commit message 5 Answers Sorted by: 6 Git commit only saves it to the stage, which is locally on your computer. When you get editor up as a result of issuing the above, take a look at the comment in the opened file: # Commands: where -i is the interactive flag, and HEAD~5 means include the last 5 commits in the interactive rebase. If you want to revert the last commit just do git revert then you can push this new commit, which undid your previous.As others have said: $ git rebase -i HEAD~5 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |