I checkouted specific commit from my project and continued from there, hoping that changes after that commit would be deleted, and that commit I checkouted would be new head. I commited new changes, but I can't push them. I'm still new to git.
What I have done is:
- git checkout commit_hash
- edited project
- git commit -m "new changes"
- git push -u origin master
I got:
To https://github.com/myusername/project.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/miloradsimic/ISA16.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
When I typed git status I got:
HEAD detached from 506f0ec nothing to commit, working directory clean
I changed project hierarchy, in head commit, so I want to get it back on previous state. I dont want to merge it with head.
I did it this way (easy way, not professional): I had in one folder project with changes, not positioned on head. I downloaded head commit into new folder, and copied all files (except git files) from folder with my changes to this folder. Removed unnecessary files. Added all changes, commited and pushed.
Thanks, Milorad Simic