9/26/2023 0 Comments Git stash files by nameStupid commit message formatting requirements. # follow prompts to change the commit message Oh shit, I need to change the message on my last commit! git commit -amend Warning: You should never amend commits that have been pushed up to a public/shared branch! Only amend commits that only exist in your local copy or you're gonna have a bad time. You could also make the change as a new commit and then do rebase -i in order to squash them both together, but this is about a million times faster. and FML, I didn't put a space after an equals sign. This usually happens to me if I commit, then run tests/linters. # now your last commit contains that change! Mega hat tip to the many many many many many people who suggested adding it! Oh shit, I committed and immediately realized I need to make one small change! # make your change You can use this to get back stuff you accidentally deleted, or just to remove some stuff you tried that broke the repo, or to recover after a bad merge, or just to go back to a time when things actually worked. # each one has an index find the one before you broke everything # you will see a list of every thing you've Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?! git reflog So here are some bad situations I've gotten myself into, and how I eventually got myself out of them in plain english. Git documentation has this chicken and egg problem where you can't search for how to get yourself out of a mess, unless you already know the name of the thing you need to know about in order to fix your problem. I hope that this helps you avoid my same nightmare.Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. My commit appeared exactly as expected: the files in the folder were renamed. I committed my changes, then ran git reset -hard HEAD to get rid of those untracked new files. I then added everything except for the new files in the petstore folder which git oddly claimed were deleted, for whatever reason. Then, I changed ignoreCase back to false. git/config file to temporarily ignore case again. The fix that I found that worked was to temporarily edit my. I could not apply my stashed changes to this other branch. git/config file to stop ignoring case, made changes, squashed my commits, and stashed my changes to move to a different branch. I encountered this issue when I renamed a folder from "Petstore" to "petstore" (uppercase to lowercase). This turns out to be a nightmare when you rename them to the exact same name with a different case. It would be great to replace steps 1-3 with porcelain command, but I'm not aware of any equivalent.įor those who don't know, git ignores uppercase/lowercase name differences in files and folders. We use -rf to force delete and remove untracked directories. git pull 2>&1|grep -E '^\s'|cut -f2-|xargs -I " and call rm for each of them. This snippet will extract all untracked files that would be overwritten by git pull and delete them. If you have other untracked (possibly ignored) files in the directory this method won't remove them. The method presented here removes only files that would be overwritten by merge. How this answer differ from other answers?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |