Question

I have been working with a series of classmates on a project. An accident caused me to make a mess of my own repository to the point where it's unusable, and I'm not sure when the issue occurred. I believe it's easier to simply empty out my repository, and pull from the latest of my classmates' commits, but when I do this, nothing happens. My repository is still blank.

We all have forked from the teacher's base repository, and we're using Git Extensions, since we're all new to Git (but required to use it for the class.)

enter image description here

I'm trying to revert to Shade's commit earlier in the day entitled "Updated Game," but I don't know how to go about that. How do I go about this process?

Was it helpful?

Solution

You will rapidly get frustrated with the GUI when trying to do anything but the simplest stuff with Git. This is one of those times where you do something more complicated, and you need to use the terminal ;). Run:

git checkout master
git reset --hard Shade/master

Note that this will destroy any uncommitted work.

Now master will point at the commit that Shade/master is pointing to. This is the answer to your question. But! There is a catch that you should consider. By restting your master behind origin/master, you've created a situation where you can't push to origin/master anymore, because origin would reject the non-fast-forward push. What you have to do is "dummy merge" origin/master into your local copy, like this:

git merge --ours origin/master -m "Fix botched work"

The --ours flag discards any changes in the other branch that might otherwise have been merged in. Now you can push without origin complaining.

Hope that helps!

OTHER TIPS

Use git log to get the commit hash like 43566df6a26a31a2d44ad102ffa241a0ab55edde. You can use git checkout and then git checkout -b to make a new branch from that point. You can also delete the old branch with git branch -D git branch -m supports moving (renaming) the new branch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top