git rebase 后找回消失的commit
生活随笔
收集整理的這篇文章主要介紹了
git rebase 后找回消失的commit
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
git rebase 后找回消失的commit
在git rebase操作時(shí),存在沖突時(shí),使用git rebase --abort處理后,結(jié)果發(fā)現(xiàn)commit的修改和記錄都沒有了。(使用git rebase --skip處理,也有導(dǎo)致commit消失不見得情況),就是使用git log看不到。
并不是真的在git中完全消失了。
這是可以使用reflog命令列出log 信息。
reflog : reference logs
這里顯示了commit 的sha, version, message,找到你消失的commit,然后可以使用這個(gè)‘消失的’commit重新建立一個(gè)branch.
$git checkout -b branch-bak [commit-sha]然后可以出來沖突,再git add, git commit, git push等操作,把修改提交。
最后,看看git help
NAMEgit-reflog - Manage reflog informationSYNOPSISgit reflog <subcommand> <options>DESCRIPTIONThe command takes various subcommands, and different options depending on the subcommand:git reflog [show] [log-options] [<ref>]git reflog expire [--expire=<time>] [--expire-unreachable=<time>][--rewrite] [--updateref] [--stale-fix][--dry-run] [--verbose] [--all | <refs>...]git reflog delete [--rewrite] [--updateref][--dry-run] [--verbose] ref@{specifier}...Reference logs, or "reflogs", record when the tips of branches and other references were updated in the localrepository. Reflogs are useful in various Git commands, to specify the old value of a reference. For example,HEAD@{2} means "where HEAD used to be two moves ago", master@{one.week.ago} means "where master used to point toone week ago in this local repository", and so on. See gitrevisions(7) for more details.This command manages the information recorded in the reflogs.The "show" subcommand (which is also the default, in the absence of any subcommands) shows the log of thereference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and inaddition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit--pretty=oneline; see git-log(1) for more information.The "expire" subcommand prunes older reflog entries. Entries older than expire time, or entries older thanexpire-unreachable time and not reachable from the current tip, are removed from the reflog. This is typicallynot used directly by end users -- instead, see git-gc(1).The "delete" subcommand deletes single entries from the reflog. Its argument must be an exact entry (e.g. "gitreflog delete master@{2}"). This subcommand is also typically not used directly by end users.OPTIONSOptions for showgit reflog show accepts any of the options accepted by git log.Options for expire--allProcess the reflogs of all references.--expire=<time>Prune entries older than the specified time. If this option is not specified, the expiration time is takenfrom the configuration setting gc.reflogExpire, which in turn defaults to 90 days. --expire=all prunesentries regardless of their age; --expire=never turns off pruning of reachable entries (but see--expire-unreachable).--expire-unreachable=<time>Prune entries older than <time> that are not reachable from the current tip of the branch. If this option isnot specified, the expiration time is taken from the configuration setting gc.reflogExpireUnreachable, whichin turn defaults to 30 days. --expire-unreachable=all prunes unreachable entries regardless of their age;--expire-unreachable=never turns off early pruning of unreachable entries (but see --expire).--updaterefUpdate the reference to the value of the top reflog entry (i.e. <ref>@{0}) if the previous top entry waspruned. (This option is ignored for symbolic references.)…………總結(jié)
以上是生活随笔為你收集整理的git rebase 后找回消失的commit的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mac中修改系统限制量--ulimit和
- 下一篇: 火狐浏览器 Firefox 109.0.