Git Checkout Tricks You've Never Heard Of
Want to know one of my favorite git secrets? It has to do with
Sometimes you’ve made and committed files that shouldn’t be there. Stuff like
console.logs you forgot to remove. You can mess around with
git cherry-pick or
git revert but that can be a hassle sometimes.
If you have a file called
screens/MyScreen.js that you want to completely reset based off
master, run this:
git checkout origin/master -- my/file/whatever.js
This works with other branches or folders, just replace
any-branch-name and the file with the folder name:
git checkout origin/any-branch-name -- folderName
Running this will completely reset the file and get you back on track to merge your PR in!
Have your own tricks? Let me know.