I am following an online course which includes some exercises using notebooks hosted on a github repository.
I forked their repository in github and then cloned it to work locally on the exercises. I did not take the precaution of creating a separate branch before making my changes - which in retrospect may not have been a such a great idea.
Now I have found a typo on one of the files and would like to send the authors a pull request so they can review and fix it. I only want to include in the pull request the correction for this typo, but not everything I modified in the files to solve the exercises.
My intention was to revert to the original version of the repo that I downloaded (before I made any changes), from that point create a new branch, fix the typo there and send a pull request from that branch but I am struggling. For context: I did a course on git and github a couple of months ago but have very little practical experience.
I tried to do that by issuing git log --oneline --graph -all
to ID the relevant COMMIT_ID then git checkout COMMIT_ID
to revert there. Unfortunately this didn't work as I expected. git informed me I was in 'detached HEAD' state and proposed to create a new branch with the committed changes using git switch -c NEWBRANCH
. I tried, but from this new branch I can still see all the modified files (just they are not added to the commit yet, but the changes are still there), and in addition the remote repo is not the original one but the one I forked to my github.
I could manually change the remote, manually undo the changes in the files... but I have the strong feeling I am doing something wrong. There must be an easy way to do this.
Could anyone help me understand what I am doing wrong, and find a better way to do it?