StuartM
StuartM

Reputation: 6823

Reverting commited changes for local changes

I have made a bunch of changes to a repo.

When the changes were completed I completed a stage, staging all those changes. Then committed them locally.

Once complete I attempted a push, but the repo had changed.

I then completed a rebase (instead of merge) on the master. This found a conflict on a small JSON file.

This was the only conflict that showed, I clicked continue to (what I thought) would merge that in. However, my commit has now been pushed with only that single file change.

The other file changes have disappeared. Is there a way to get those back?

Upvotes: 0

Views: 112

Answers (1)

LateCoder
LateCoder

Reputation: 2283

As long as you committed the changes need, you can get back those changes.

  1. You need to know which commit hash is associated with those changes. To find out, you can do a git log.
  2. Once you find the necessary commit hash, you can checkout all the files from that commit by doing git checkout commit-hash (where "commit-hash" is the hash you found), or you can checkout individual files into the repository in its current state by doing git checkout commit-hash path-to-file.

Upvotes: 1

Related Questions