I'm new on github. All I do is commit and push my workI did commit my work few times, but I don't know what happened it reverted back to the first commit. Got no clue my last commit id. I want my last commit, how to do that? Edit: Got this syntax from Paul S. link: PS C:\xampp\htdocs\osposs> git log --reflog commit aa8447b79cb3e500ca1dc84b97baf8e006bac746 Author: adell Date: Sun Jan 2 15:45:22 2022 +0700 I want to revert back to that last commit ---------- tried to open .git folder commit (initial): first commit moving from master to DDsalespluscredittermsofcustomer moving from DDsalespluscredittermsofcustomer to 764c7d3bcb6eada2bb3d984c527d6787d1e186bf commit1 Commit2 commit3 commit4 commit5 commit6 8c83f08e0834b04ab9bbd16479b864ebc08d4af6 aa8447b79cb3e500ca1dc84b97baf8e006bac746 adell 1641113122 +0700 commit: Add new text-align checkout: moving from aa8447b79cb3e500ca1dc84b97baf8e006bac746 to master moving from master to master moving from master to DDsalespluscredittermsofcustomer moving from DDsalespluscredittermsofcustomer to master moving from master to master ----------------------------- PS C:\xampp\htdocs\osposs> git checkout aa8447b79cb3e500ca1dc84b97baf8e006bac746 error: The following untracked working tree files would be overwritten by checkout: .gitignore .htaccess Dockerfile INSTALL.md LICENSE README.md ... Aborting PS C:\xampp\htdocs\osposs> git status On branch master No commits yet ---------- What should I do? Thanks for help.. really T.T
Asked
Active
Viewed 43 times
0

Adell
- 11
- 1
-
1If you force-pushed your local copy (your machine) over the top of the remote copy (github) you could have suffered data loss on the remote. Assuming that your local copy had all the data at some point before you did this (and you did not perform a garbage collection), you may be able to find the lost data in your reflog https://stackoverflow.com/a/34548567/1615483 – Paul S. Jan 02 '22 at 10:06
-
for my personal note.. Finally I know the problem, this project is on my local repository, somehow not connected to remote github. The last commit is on branch "DDsalespluscredittermsofcustomer". I did this: 1. download github desktop 2. clone rep (htdocs/projectX/.git (then I tried to move to DD branch but failed, "is a directory blablabla", "git add -A" return "git does not have a commit checked out. fatal: adding files failed", "checkout -f HEAD" return error "error: pathspec 'HEAD' did not match any file(s) known to git") – Adell Jan 03 '22 at 05:30
-
3. Commit from VS Code (even this one is wrong files, files that already revert to 2nd commit) git checkout -f DDsalespluscredittermsofcustomer". Github return "Checking out files: 100% (9185/9185), done. Switched to branch 'DDsalespluscredittermsofcustomer'" 4. Checkout from last commit "git checkout aa8447b79cb3e500ca1dc84b97baf8e006bac746". DONE – Adell Jan 03 '22 at 05:38