1

I'm really new in Git, just read Bitbucket tutorial.

I did some wrong commit for a .txt file. How can I delete any future commits and remarks that I did them on Bitbucket?

First I did

git reset --hard <commit_ID>

then

git reset --hard HEAD~1

several times

git status

Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded.

What should I do?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Imugi
  • 161
  • 1
  • 3
  • 13
  • To push these changes upstream, you can force push using `git push -f`. If there are other people who might be using your project, use `git reset` instead. – 0xcaff Jan 20 '16 at 23:01
  • Possible duplicate of [Resetting remote to a certain commit](http://stackoverflow.com/questions/5816688/resetting-remote-to-a-certain-commit) – palimpsestor Jan 20 '16 at 23:03

2 Answers2

1

You have reseted your local branch 4 times back but your origin/master has the last state before. To overwrite them you have to use git push -f for force to push your local changes to the remote branch and force them back to your state.

When you push something with force its possible that other people get trouble when they push them.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
1

git reset --hard HEAD~x will remove the last x commits from the current commit that the HEAD is at (basically the current status of your local repo). Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded. means that there are 4 commits on your "git server" (the origin remote) or wherever your remote data is being stored (ex. GitHub). Deleting local commits with reset will remove them from your machine only and not from the server. If you want to remove them everywhere and replace the state of the server with the state you have locally you can run git push -f which forces the push and overwrites the server data with your local data.

Zach P
  • 560
  • 10
  • 30