1

制作 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

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

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. 如何恢复已删除/新文件?

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

4

1 回答 1

1

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

于 2021-07-15T22:03:31.543 回答