git回退某一个版本的某个文件

需求是有个文件需要退回到某个指定版本的状态,直接上命令
查看帮助说明:

git checkout -h

$ git checkout -h usage: git checkout [] or: git checkout [] [] -- ...-q, --quietsuppress progress reporting -b create and checkout a new branch -B create/reset and checkout a branch -lcreate reflog for new branch --detachdetach HEAD at named commit -t, --trackset upstream info for new branch --orphan new unparented branch -2, --ourscheckout our version for unmerged files -3, --theirscheckout their version for unmerged files -f, --forceforce checkout (throw away local modifications) -m, --mergeperform a 3-way merge with the new branch --overwrite-ignoreupdate ignored files (default) --conflictconflict style (merge or diff3) -p, --patchselect hunks interactively --ignore-skip-worktree-bits do not limit pathspecs to sparse entries only --ignore-other-worktrees do not check if another worktree is holding the given ref --progressforce progress reporting

一看就知道要用哪个命令:
git checkout [] [] -- ...

那么执行的时候就是这个样子:
git checkoutee25a1a3f9465 config/database.php

如果要回退整个文件夹到某个版本呢?
git checkout e2fb85c827d24a460d app/Http/Controllers/Auth

git强制回退到上一个版本:
git reset --hard HEAD^

git回退到指定版本:
查看log历史一行一条:
git log --pretty=oneline

回退:
git reset --hard 版本号

注意:这个命令是不会保留指定的那个版本到现在本地的修改的,去掉–hard参数,就可以保留修改,执行完之后可以git status看到。
【git回退某一个版本的某个文件】http://gitbook.liuhui998.com/index.html

    推荐阅读