git checkout表示文件未提交,但确实是?

时间:2019-04-28 09:11:08

标签: git

(project_venv) jojo@jojo-System-Product-Name:~/project_fresh/examples/relational_preloadstack1/relational_stack1-layernormordertest-pkl$ git commit -m 'Huh'
On branch refactoringNormalizerIntoPreprocessingFnx
Changes not staged for commit:
        modified:   ../current_preload_relationalstack1_to_relationalstackn/preload_stack2_relational.py
        modified:   ../current_preload_relationalstack1_to_relationalstackn/resume_training_with_new_env.py
        modified:   ../current_preload_relationalstack1_to_relationalstackn/trace.html
        modified:   ../timing_test.py
        modified:   ../../../project/torch/core.py
        modified:   ../../../project/torch/sac/twin_sac.py
        modified:   ../../../scripts/convert_gpu_model_to_gpu.py
        modified:   ../../../scripts/download_s3.py
        modified:   ../../../scripts/inspect_hd5.ipynb
        modified:   ../../../scripts/sim_goal_conditioned_policy.py

no changes added to commit
(project_venv) jojo@jojo-System-Product-Name:~/project_fresh/examples/relational_preloadstack1/relational_stack1-layernormordertest-pkl$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
        examples/relational_preloadstack1/current_preload_relationalstack1_to_relationalstackn/preload_stack2_relational.py
        examples/relational_preloadstack1/current_preload_relationalstack1_to_relationalstackn/resume_training_with_new_env.py
        examples/relational_preloadstack1/current_preload_relationalstack1_to_relationalstackn/trace.html
        examples/relational_preloadstack1/timing_test.py
        project/torch/core.py
        project/torch/sac/twin_sac.py
        scripts/convert_gpu_model_to_gpu.py
        scripts/download_s3.py
        scripts/inspect_hd5.ipynb
        scripts/sim_goal_conditioned_policy.py
Please commit your changes or stash them before you switch branches.
Aborting

为什么在这里尝试检出master分支会出现“请提交更改...”错误?您可以从上一个命令中看到我已经添加了所有更改并将它们提交给'refactoringNormalizerIntoPreprocessingFnx'分支

1 个答案:

答案 0 :(得分:2)

您正在尝试提交更改,而没有告诉git 要使用哪些文件。

在创建提交(使用git commit -m "Huh")之前,您需要git add要包含的相关文件。

例如,要向更改添加<​​strong>单个文件,您可以执行以下操作:

git add ../current_preload_relationalstack1_to_relationalstackn/preload_stack2_relational.py

如果您只想添加所有已更改的文件,则可以执行此操作(从项目的根文件夹):

git add .

请注意,这还将向您的提交中添加“未跟踪”文件-这意味着过去不受git控制的文件。

添加文件后,可以再次运行git status,并且会看到“已暂存以提交”的文件列表。一旦有了这个,就可以添加您的提交:

git commit -m "Huh"

现在,当您执行git status时,应该会看到“什么也没提交”的消息。

相关问题