gpt4 book ai didi

如果自上次提交以来已将新文件添加到项目中,Qt Creator 中的 Git stash 将失败

转载 作者:太空狗 更新时间:2023-10-29 12:54:05 25 4
gpt4 key购买 nike

自上次提交以来,当我刚刚对项目中的文件进行更改时,git stash 工作正常。

但是,如果自上次提交后我还向项目添加了新文件,则会失败并出现以下错误:

C:\Program Files\Git\cmd\git.exe stash save QtCreator 2013-01-08T12:06:51
Cannot stash in "C:\MyProject": error: Entry 'NewFile.cpp' not uptodate. Cannot merge.
Cannot save the current worktree state

为什么会显示此错误,如果我向项目添加了新文件,是否有办法 stash 我的更改?

编辑

这是 git status 的输出

# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: NewFile.cpp
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: MyFile.cpp
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# MyProject.pro.user

最佳答案

正如 Scott Chacon 所说,

Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.

因为你添加了一个新文件然后它不知道因为它以前不存在,所以尝试这样做:

1) $ git add .
2) $ git stash

看看你是否能够存储这些更改

关于如果自上次提交以来已将新文件添加到项目中,Qt Creator 中的 Git stash 将失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14212612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com