So here's an in-depth detail story of my situation timeline regarding a project I'm working on. Bear in mind that everything was done in the same single master branch.
- Yesterday - Made some commits in the project's remote repository by updating the README file and adding a LICENSE agreement file.
- Today, at 08:00AM - Decided to work on my project and write some code, didn't pull or fetch anything from the remote repository.
- 17:34PM - Had 7 commits in my local repository. Decided to push my local commits to the remote repo to call it a day and then in doing so, git warned me that the local and remote repositories had diverged. Because I suck at git, I copied the files I had worked on into another folder (for precaution reasons, didn't want to lose my work) and then typed the following commands to try and solve the problem :
git fetch git pull git commit git reset --hard origin/master git fetch git pull
I'm thinking that with all these, the following happened :
- My local commits went to zero
- I pulled everything from the remote repository, replacing the work I had done in my local machine
- Problem seemed to be solved (on the surface at least) because the repositories were in sync again.
I then deleted all the files and pasted in their place, the files with all the code work I had previously copied. The following commands had the purpose of :
- Get back the LICENSE file I had deleted
- Push everything to the remote repository to finally end this issue
git checkout LICENSE git add --all git commit -am "don't know what the hell am I doing" git push
Now I've just realized that I forgot about the README file. Aside from the LICENSE file, it was the only thing from the remote repository that I actually needed to fetch and I deleted along with all the other files pulled from the remote repository.
Unfortunately, I can't do git checkout README
to recover it because I already pushed everything.
Could someone give me some advice on what I'm doing? How can I navigate better with git?