欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Git恢复删除分支

程序员文章站 2022-05-25 23:37:06
...

删除

       git branch -d 名字

       git branch -D 名字 (强制删除)

       删除的时候会显示哈希码

恢复

      git checkouot -b 新名字 哈希码

哈希码

    git reflog

代码

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (ddd)
$ git cbranch -d ddd
git: 'cbranch' is not a git command. See 'git --help'.

The most similar command is
        branch

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (ddd)
$ git checkout master
Switched to branch 'master'
M       "PHP\344\274\232\350\257\235\347\273\203\344\271\240/1.cookie.php"
Your branch is up to date with 'origin/master'.

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git branch -d ddd
Deleted branch ddd (was 1a773de).

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   "PHP\344\274\232\350\257\235\347\273\203\344\271\240/1.cookie.php"

no changes added to commit (use "git add" and/or "git commit -a")

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git checkout -d eeee 1a773de
fatal: git checkout: --detach does not take a path argument 'eeee'

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git checkout -b eeee 1a773de
Switched to a new branch 'eeee'
M       "PHP\344\274\232\350\257\235\347\273\203\344\271\240/1.cookie.php"

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (eeee)
$ git status
On branch eeee
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   "PHP\344\274\232\350\257\235\347\273\203\344\271\240/1.cookie.php"

no changes added to commit (use "git add" and/or "git commit -a")

[email protected] MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (eeee)
$ git reflog
1a773de (HEAD -> eeee, origin/master, master) [email protected]{0}: checkout: moving from master to eeee