git 存储后如何更好地恢复修改后的文件?

How better to restore modified files after git stash?

制作git pull 我有错误:

error: Your local changes to the following files would be overwritten by merge:
        public/js/file.js
        public/file.json
Please commit your changes or stash them before you merge.

我用

保存了所有修改文件的列表
git status

和命令运行

git stash

我合并了所有文件,现在我需要恢复所有更改。所有文件的列表相当大,包括 deleting/new 个文件,例如:

On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    app/Http/Controllers/ItemController.php
        new file:   app/Http/Controllers/BoxController.php
        
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   app/Http/Controllers/ItemController.php
        
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        app/Http/Controllers/ItemController.php
        app/Http/Requests/ItemRequest.php

当我需要恢复一些修改过的文件时,我可以手动应用更改,但是

  1. 如何恢复deleted/new个文件?

  2. 是不是所有修改过的文件列表比较大,如何才能更好,而不是手动一一检查?

要恢复您的更改,请执行 git stash apply。但是,看起来您的合并不完整。在尝试应用您的存储之前,您需要 git commit 合并。