1

I am new to GitHub and am currently learning to work on a public repository. I have forked the repository and have two branches created (master and testing). I work on the testing branch.

Accidentally I changed two files of the remote repository that were not supposed to be changed and created a pull request. Of course, my request was discarded because of those changes and I was asked to revert the changes from those two files. I tried to revert the changes using many methods available on the internet and also some of my own. (like manual copy-paste from git), git revert and others.

Now, when I run git diff <testing> origin/master , I do not see the two forbidden files. Does that mean there's no difference in them ?

Can someone explain to me how to check differences in particular files from remote repository ? And can someone also explain how to revert forbidden changes and create a new pull request.

Thanks alot in advance.

Gauraang Khurana
  • 694
  • 1
  • 5
  • 15

1 Answers1

0

Since you told us that you created a pull request with unwanted modifications to two files, I will assume therefore that you have already committed those changes.

If the commit in question is the most recent commit in the testing branch then you can try resetting those two files to the immediately prior commit and then amending the commit:

git checkout testing
git checkout HEAD~1 -- path/to/file1.ext
git checkout HEAD~1 -- path/to/file2.ext
# git add, if needed
git commit --amend
git push --force origin testing
Tim Biegeleisen
  • 387,723
  • 20
  • 200
  • 263
  • Shouldn't it be `git push origin +testing` to force update the github repo? – maazadeeb Oct 31 '17 at 07:44
  • @TimBiegeleisen : Can you tell me why I don't see those two files when I run. 'git diff origin/master' – Gauraang Khurana Oct 31 '17 at 13:56
  • @GauraangKhurana I seldom run `git diff`, but according to [this very highly voted answer](https://stackoverflow.com/questions/822811/showing-which-files-have-changed-between-two-revisions), the syntax you should be using is this: `git diff --name-status testing..origin/master` – Tim Biegeleisen Oct 31 '17 at 14:11
  • Hey, I tried to run your commands and got stuck. Earlier I had done a rebase by mistake and had to reset it. Now I cannot run the command stated here - 'git commit --ammend' This shows my errors. Can you guys please help. https://stackoverflow.com/questions/47037433/stuck-while-trying-to-undo-a-rebase – Gauraang Khurana Oct 31 '17 at 14:20