-3

I am using bitbucket using git. My recent changes have affected the working of my project. As a result, I would like to overwrite all my recent changes.

I need my master branch to contain only those changes till a previous commit with commit id say 'b43fbf'.

What is the git command to do this.

Philip John
  • 5,275
  • 10
  • 43
  • 68
  • 4
    possible duplicate of [Revert to a previous Git commit](http://stackoverflow.com/questions/4114095/revert-to-a-previous-git-commit) – MrTux May 14 '15 at 13:44

1 Answers1

2

Run git reset --hard b43fbf

This resets your current branch and your working tree to the commit b43fbf (all changes are then lost).

For other options see How to revert Git repository to a previous commit?

Community
  • 1
  • 1
MrTux
  • 32,350
  • 30
  • 109
  • 146
  • It worked. but now it is in a detached HEAD state. I am not able to push because of that. – Philip John May 14 '15 at 14:14
  • Then you were on detached HEAD state before. Make sure you are on the master branch e.g. by "git checkout master --force" and then issue the reset command. – MrTux May 14 '15 at 14:36
  • But beware that, as the names suggest, `reset --hard` and anything including `--force` are dangerous commands. Understand what you're doing before running them. – Matthieu Moy May 15 '15 at 11:34