Ashish Ranjan
Ashish Ranjan

Reputation: 12970

How to get changes done by me one commit back?

I had lots of changes in my local git fork, I do:

  1. git add -A
  2. git commit -m "commit message"
  3. pull changes from upstream master
  4. rebase
  5. git push to my origin

Now It happens that there are several other commits (from others) between my previous commit and my new commit.

I want to see all the changes done by me in my new commit and work on it. So, I do

git reset --soft <my previous commit>

It shows files modified by me and also by others.

Question:

  1. What would be the way to see files modified only by me?
  2. And then the files are shown as modified, is it possible to unstage them? I want to see the changes when I do git diff.

Upvotes: 2

Views: 2483

Answers (2)

Sajib Khan
Sajib Khan

Reputation: 24204

You can filter only your commits then compare with HEAD.

$ git log --author=<user>           # see your  commits and copy commit-sha
$ git diff <commit-sha>..HEAD       # shows what is in HEAD that is not in <commit>

Upvotes: 2

Yaser
Yaser

Reputation: 5719

You are making things so complex. Instead of soft reset, simply use git diff and pass your commit and the one before to see what has been changed:

git diff xxxxxx yyyyyy

Where xxxxxx is the first and yyyyyy is the second commit hash values. To get the commit hash value use git reflog.

More info here.

UPDATE:

As suggested in comments, you can also use git difftool xxxxxx yyyyyy for a visual diff.

Upvotes: 5

Related Questions