Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "time travel" git repository back in revisions?

Is it possible to completely revert git repository to previous X revision on bitbucket so that it doesn't keep any changes after that X revision and doesn't contain any source code change newer than X revision.

For example if there are 1,2,3,4,5 revisions in the repo and i want to revert to revision 3, so that it's the last revision and completely wipe out any trace of revisions 4 and 5 as if they never were made and can't be retrieved.

like image 395
user358448 Avatar asked Mar 05 '23 23:03

user358448


1 Answers

Yes, you can do this there many ways to do this:

1) you can specify the time like 10.minutes.ago, 1.hours.ago, 1.days.ago ...

Ex: if you want to go back 5 days ago on the master branch git reset --hard master@{5.days.ago}

2) if you know the commit hash then you can go back to it directly git reset --hard <commit_hash>

Thanks!

like image 177
rahul mishra Avatar answered Mar 10 '23 09:03

rahul mishra