Somehow I have a really large local repository because I added over 2 GB of files by accident and without thinking tried to push this. I aborted, removed the files and did a recommit, but when I try to git push origin master
to Bitbucket, it fails with:
fatal: The remote end hung up unexpectedly
My .git file is still huge, even though I have since long removed the unneeded files. Since the push is over 2 GB, Bitbucket says I need to set the http.postBuffer
to a higher number. I've done this many times but after about 15 tries I want to just start over.
git status
gives me this:
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
(use "git push" to publish your local commits)
But since the push never works, how do I fix it? Worst case scenario I could just blast the repo and rebuild it, but I'd like to know if there is a way to reset the push since it keeps failing.
To revert, you can: Go to the Git history. Right click on the commit you want to revert. Select revert commit.
Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .
To undo changes associated with a specific commit, developers should use the git revert command. To undo every change that has happened since a given commit occurred, use git reset.
The weigreen’s answer will help when the problematic commit is the most recent one, in other cases you’ll need to rewrite the history. I would prefer an interactive rebase.
git rebase -i <some-commit-before-the-problematic-one>
It will display the list of commits along with the default action to pick
them as they are. If you want to keep a part of the problematic commit, change pick
to edit
on that line. If you prefer to remove it at all, just delete the line. If you choose to edit that commit, Git will put the working tree into the state like when you’ve just done the problematic commit. Change what you need and amend the commit:
git commit --amend
After that, let Git finish the rebase using
git rebase --continue
You can do it by git reset
git reset --hard <commit-id>
You can get commit-id by using git log
You will lose all your work between HEAD and the commit you selected
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