I decided to integrate a library into my code. I add the library, and change a couple lines of code to start implementing it. It compiles, so I commit and push to the repo.
I only realise later that I've missed a line that is still on old code.
I give it a google search and find out about git commit --amend
, and lucky for me, there are no other commits.
I thought all I had to do was fix the line of code, git add
the file, git commit --amend
, and finally git push
that to the repo, but git tells me
! [rejected] master -> master (non-fast-forward) hint: Updates were rejected because the tip of your current branch is behind
I find that strange since I'm on the latest commit and if I git reset -soft HEAD~1
I am back to being aligned with the repo, besides the single line of code I've changed.
Am I doing it wrong? I really don't want to make an entirely new commit just for this single line of code that should've been part of the last commit.