Some bad Git situations and how I got myself out of them
1–10 of 352 posts
Re: Some bad Git situations and how I got myself out of them
#2 git reset --hard origin/master
(assuming that the remote is called "origin") With the example in the text, you have to know the number of commits you've made to master.Re: Some bad Git situations and how I got myself out of them
#3Re: Some bad Git situations and how I got myself out of them
#4Re: Some bad Git situations and how I got myself out of them
#5http://stackoverflow.com/questions/28759887/git-gc-no-space-...
Re: Some bad Git situations and how I got myself out of them
#6Re: Some bad Git situations and how I got myself out of them
#7If you don't then there are ry only two things you need to know how to do:
If you didn't push to origin do an ammend. If you did, revert soft and commit the previous code to revert it (you can also put a stash or patch to apply it back).
Which frankly is what the article does, basically.
Re: Some bad Git situations and how I got myself out of them
#8The screwed up and committed to master should end with: git reset --hard origin/master (assuming that the remote is called "origin") With the example in the text, you have to know the number of commits you've made to master.
git branch some-new-branch-name
git reset --hard origin/master
git checkout some-new-branch-nameRe: Some bad Git situations and how I got myself out of them
#9Re: Some bad Git situations and how I got myself out of them
#10Other ways to do it (that don't require to retype the commit message): - rebase onto the correct branch:
git branch foo
git reset --hard HEAD~
git rebase --onto name-of-the-correct-branch HEAD foo
git checkout name-of-the-correct-branch
git merge foo
git branch -D foo
- cherry-pick git reset --hard HEAD~
git checkout name-of-the-correct-branch
git cherry-pick name-of-the-branch-you-mistakenly-committed-to@{1} (or git cherry-pick HEAD@{2})
> Oh shit, I tried to run a diff but nothing happened?!You probably want to know `git diff HEAD` too.
Edit: formatting.