Jaqueline
Jaqueline

Reputation: 485

Reverting to a previous version git repo

Hello so I've done this before I just completely forgot how.

What I am trying to do is I have a remote on my github repo and I have an old version that I would like to revert to meaning I can commit from it and it would now be at the top of the repo if that makes sense since my current repo is having some issues and I want to go back to a specific version.

I remeber slightly what I was able to find out last time which worked out beautfully and that was I checked out the version I want and then I created a new remote or split the remote or something, added the version on to the new one and then merged the branches or remotes. It was something along those lines, I just don't remember exaclty and I would appreciate someone guiding me through as I am unable to find the old posts I was previously looking at.

This is a Swift Xcode project

Thank you in advance for all of the help

Upvotes: 3

Views: 2085

Answers (2)

VonC
VonC

Reputation: 1328522

Instead of rebasing/restting your branch, you could revert the past commits you don't want, in order to create a new commit which would restore the state of the branch to the content of an older commit.

See "Git reset --hard and a remote repository"

git revert HEAD~N
git push

Upvotes: 1

HackerBoss
HackerBoss

Reputation: 829

Using terminal git, you can do git rebase -i HEAD~N where N is the number of commits you want to backtrack. Then you can choose to drop or edit commits. In your case, you only need to drop the most recent commits and then you will be effectively back to one of your previous commits. In other cases, this can be used to combine/split commits as well.

Upvotes: 0

Related Questions