9/8/2023 0 Comments Git reset to commit hash![]() ![]() The & part only runs if the return code to the previous command ( git status -porcelain) is 0, meaning "success" (clean in this case), and the || part only runs if the return code of the previous command ( git status -porcelain) is any other error code, meaning "error" (dirty in this case). If you want to commit on top of the current HEAD with the exact state at a different commit, undoing all the intermediate commits, then you can use reset to. Instead, it inverts changes introduced by the commit, and generates a new commit with the inverse content. It's important to remember that this command isn't a traditional undo operation. So, I combined this answer ( git rev-parse -short HEAD) by NarÄbski, and this answer: ( test -n "$(git status -porcelain)") by on their answer to "Checking for a dirty index or untracked files with Git", I was able to come up with my "1-line" solution above. To hard reset files to HEAD on Git, use the git reset command with the hard option and specify the HEAD. We can revert a commit in Git by using the git revert command. git log -oneline (to get the commit hash that you wish to revert) git checkout git revert (this will give you a.Just like git status will show when a submodule is "clean" or "dirty" when using Git Submodules, I really want to see my short commit hash with the word -dirty after it if git status is dirty! I'm using this inside my build system as a version number in my software, so I can easily see exactly which software version I'm running at any moment! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |