如何在我的分支中只存储多个已更改文件中的一个?


当前回答

在这种情况下,我使用gitadd-p(交互式)、gitcommit-m blah,然后在必要时存储剩余的内容。

其他回答

当您尝试在两个分支之间切换时,会出现这种情况。

尝试使用“git add filepath”添加文件。

稍后执行此行

git stash—保留索引

在这种情况下,我使用gitadd-p(交互式)、gitcommit-m blah,然后在必要时存储剩余的内容。

使用git存储推送,如下所示:

git stash push [--] [<pathspec>...]

例如:

git stash push -- my/file.sh

这是自2017年春季发布的Git 2.13以来提供的。

git add .                           //stage all the files
git reset <pathToFileWillBeStashed> //unstage file which will be stashed
git stash                           //stash the file(s)
git reset .                         // unstage all staged files
git stash pop                       // unstash file(s)

我会使用git存储保存补丁。我不觉得交互很烦人,因为在交互过程中,可以选择将所需的操作应用于整个文件。