0

I'd like to know how to revert a project I got from github to a previous version. Let's say the latest project version is 4.10, however I'd like to work with 4.9 in my code, because in 4.10 the project moved from VS2013 to 2015 and I can't use it on Win 7. I forked the project and, as far as I know, you can't clone anything else beside the latest versions (not exactly true as shown here How to clone a specific Git branch? but it's to late - I already cloned the 4.10).

So I installed 'git for windows' command-line tools to have access to git revert - which I think is required for this task. How do I revert to a previous version? Somewhere there was info I need a hash of the version I wan to get back to but where can I find that on github?

Thanks in advance, drinker

Community
  • 1
  • 1
drinker
  • 41
  • 7

1 Answers1

0

In that case, start by fetching everything from the origin; this is a lazy/comprehensive choice. You could choose to be more specific, but that should hardly matter since you already cloned most of the tree.

edit: git-fetch options that should actually work (one of these should do "the trick")

> git fetch origin

> git fetch --all

> git fetch origin -t

> git fetch --all -t

Then checkout the 4.9 branch, or tag, or commit_id (as you see fit) as a fork branch.

> git checkout -b my_fork 4.9
  • "-b" creates a new branch if it does not already exist; "-B" is like a forced version, not recommended, but available
  • "my_fork" can be named whatever you like
  • "4.9" can be changed to target any useful refspec that you like.

For the rest of the options around git-fetch and git-checkout, read the man files.

starlocke
  • 3,407
  • 2
  • 25
  • 38
  • Thanks for the quick reply. However, the line > git fetch origin --all returns: fatal: fetch --all does not take a repository argument. I checked if the variable is set correctly but it seems fine: remote.origin.url=https://github.com/sakuracz/UnrealEngine.git - I'm quite the noob when it comes to git so I have no idea what's the problem. Perhaps the knowledge that the repository is github.com/EpicGames/UnrealEngine may help shed some light on this. – drinker Dec 17 '15 at 18:03
  • Ah. Sorry about that. Anyway, just `git fetch` using one or all of the above edited versions. One of the flavours ought to do the trick. Blame it on the fact that I'm too cool to think about advanced git-fetch on a regular basis. ;) The main point is to "fetch all the branches and/or tags that are needed". – starlocke Dec 17 '15 at 18:07
  • ">git checkout -b wolol 4.9" yields: "fatal: Cannot update paths and switch to branch 'wolol' at the same time. Did you intend to checkout '4.9' which can not be resolved as commit?" – drinker Dec 17 '15 at 18:23
  • I was assuming you would have either a branch or a tag called "4.9" available. You will need to replace the term with something else. I should get bonus points for pre-emptively answering walking you through the next question "how do I find branches or tags?" -- `git branch -v --all` and `git tag` should show you what is available. – starlocke Dec 17 '15 at 18:33
  • Hehe... Now, the only local branch I have is named 'release' and it's the 4.10 version. There's a bunch of remote ones listed at "remote/origin/4.X" - how do I get those? I feel we're getting closer :P – drinker Dec 17 '15 at 19:10
  • Have you tried to apply the guidance provided? `git checkout -b my_fork origin/4.X` – starlocke Dec 17 '15 at 19:13
  • Well, there it goes. Didn't know you had to proceed the version with 'origin/'. – drinker Dec 17 '15 at 19:25
  • Right, well, sounds like it's resolved. Please vote up, and mark-as-answer if you could be so kind. :3 – starlocke Dec 17 '15 at 20:22