Does git have any pull/checkout 'nuclear option' to get the repo? I don't care about any conflicts, I don't need any of my local stuff, just want the goods so I can work.
[edit] to clarify my issues:
$ git pull
error: Your local changes to the following files would be overwritten by merge:
<...files I couldn't care less about...>
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
<...more files I couldn't care less about...>
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
git fetch downloads the latest from remote without trying to merge or rebase anything. git reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/master .
Better for you to understand the various git commands then to just find the one you need "right now" as you will come up with this situation many times and just learn piecemeal while grumbling and blaming git.
EDIT: I went ahead and tried all the options and this should do it. Thanks to pauljz in the comments.
git clean -df # remove untracked files AND directories
git reset HEAD --hard # revert any uncommitted changes
The above should be all you need.
Other options:
git pull -f # replace local files even if you have unpushed commits.
or
git reset HEAD --hard # remove unchanged, uncommitted files
git pull
or
git clean -f # remove untracked files (uncommitted files)
git pull
Sometimes the steps listed in the other answers don't work, because [rant redacted]. In that case, your "tactical nuke" option is to:
(If necessary) reset uncommitted local changes so you can switch:
git reset --hard HEAD
Create and switch to a different local branch:
git checkout -b tempBranch
Force delete the (local copy of the) branch with the issues:
git branch -D targetBranch
Checkout and switch to a clean copy of the target branch from remote:
git checkout -b targetBranch origin/targetBranch
Clean up by deleting the temporary local branch you made:
git branch -D tempBranch
If that doesn't work, the "strategic nuke" option is to delete the repo and clone it again.
You could always delete the entire folder of your existing repo, and then create a new one with git clone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With