Total noob question but I've tried the stuff I've seen online to no avail. I want to make my current head point to an earlier commit. So I look at my git log, find the commit I like, and then type 'git checkout *****'. It then makes the temporary branch (my noob understanding of it) which contains the earlier commit. What do I to make this new branch back to 'master'?
Asked
Active
Viewed 152 times
2 Answers
1
You can reset current HEAD to specific commit by using reset command:
git reset --hard <commit-id>
You need to checkout to current branch HEAD first(git checkout <branchname>
). Or git will do nothing.
Commit's that been after this commit will be forgotten by git, and will not be shown in history(but they can be easily restored from current repository reflog)

rufanov
- 3,266
- 1
- 23
- 41
1
If you are looking to revert back to a previous commit and pretty much undo the work sense then, check out git reset.
git reset --hard <commit>
will reset the code to that commit.
I would advise that you spend some time reading man git-reset first though, and perhaps make a backup just in case.

Kenneth M Burling Jr
- 19
- 4
-
1note that to "make a backup" you can do `git tag a_backup`. Then if you change your mind about the reset, you can do `git reset --hard a_backup` – M.M Oct 29 '14 at 04:56