Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Revert to an old commit in Bitbucket

I have git setup on my web hosting and on an account at Bitbucket which are both linked.

How can I revert back to my first commit on both my hosting (which I am logged into via SSH and has git installed ready and working) and on Bitbucket?

I have tried: git checkout 965a793

Then I tried with a dot on the end: git checkout .

but nothing seems to change on the Bitbucket side, when I got to git push. It says everything is up to date, even though Bitbucket is on commit cf08232

Here is a list of my three commits:

cf08232 remove the txt file
096d08f test.txt edited online with Bitbucket
965a793 Initial Commit
like image 641
me9867 Avatar asked May 25 '16 10:05

me9867


People also ask

How do I revert back to an old commit in BitBucket?

If we execute git checkout myquote2. html The repository will restore myquote2. html to the previously committed version. Alternatively, we can execute git reset --hard which will revert the whole repository to the last commit.


1 Answers

Use --force :

 git reset --hard commitID
 git push origin branchName --force

I am assuming origin is the remote of bitbucket

like image 117
khrm Avatar answered Sep 22 '22 06:09

khrm