Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrian van Vlymen
12,637 PointsHow go back to my last commit on github? git checkout HEAD 0e9457e ?
I have couple of commit on github i have couple of lists git log --oneline to see lists of commits where you want go back to there.
I have tried git checkout HEAD 0e9457e3f14d62ffb95bf276975486779098b748 (copy full of SHA) that was not match any files
git reset HEAD 0e9457e3f14d62ffb95bf276975486779098b748 git checkout 1.html.
and also git reset HEAD 0e9457e git checkout 1.html
it was not change anything. Do you have any idea why its not changing anything?
5 Answers
Ryan Farber
5,329 PointsShould do the trick:
http://stackoverflow.com/questions/4114095/revert-to-a-previous-git-commit
Let me know if it works
Gloria Dwomoh
13,116 PointsI took notes about that today and it seems you need to follow git reset with --hard or --soft ex. git reset --hard HEAD <file> (there are more options available though) according to if you want to do, before adding the rest. I wonder why you are doing both reset and checkout though. These are better to use on unpublished files. If you have pushed the file then you better do something else to revert it like... "git revert".
Brian van Vlymen
12,637 Pointsit was working revert on github bash command line showing change a file. It refused to "git push" on same branch so I decided make a new branch and it was working to push and updated everything to github.com and git log lists along remove some lists. I am having problem the old branch http://imgur.com/zB2m4Hi
Gloria Dwomoh
13,116 PointsCheck this out - Cannot push to github - keeps saying need merge.
Nick Ocampo
15,661 PointsShort answer: If you just want to go back to the last commit and don't care about losing your uncommitted changes:
git reset --hard
Brian van Vlymen
12,637 PointsI managed to fix this scenario using 'git push -f' which seemed to make git forget about its imaginary problems :)
Gloria Dwomoh
13,116 Pointscool :)