I have been using git incorrectly I believe, I have been staging and committing then when I have made mistakes, I have been checking out a previous version and repeating the process, staging and committing, this has been working fine until I have tried to push my project to Github.
for example: commit #10 I made a mistake so I checked out to commit #6 and carried on now I am at say commit #20 and I want to push my repository to github
git status gives me
HEAD detached from 0ade9cbf
nothing to commit, working tree clean
I am asuming 0ade9cbf is the master I should have been on.
git log --oneline
d360cf5f (HEAD) App still works updated dependancies and fixed a few errors need to update database
0ade9cbf (origin/main, my-temporary-work) This was the last commit before moving to remote repo
my problem lies in when i want to push to github i get the following
git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
Am i correct in thinking because I have been checking out to previous versions I have lost the master way back and i should
git checkout master
git merge d360cf5f
to bring the master up to the head ?
Then I can branch the repository work on it if i'm happy with it merge with the master ?
I have just read Ry's Git tutorial, probably should have read this first.