git - git checkout 说文件没有提交,但它们是吗?
问题描述
(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
为什么尝试签出主分支会在此处给出“请提交更改...”错误?你可以从前面的命令中看到我已经添加并提交了所有更改到“refactoringNormalizerIntoPreprocessingFnx”分支
解决方案
您正在尝试提交更改而不告诉 git哪些文件用于提交。
在创建提交之前(使用git commit -m "Huh"
),您需要git add
包含要包含的相关文件。
例如,要将单个文件添加到更改中,您可以执行以下操作:
git add ../current_preload_relationalstack1_to_relationalstackn/preload_stack2_relational.py
如果您只想添加所有已更改的文件,您可以这样做(从项目的根文件夹):
git add .
请注意,这也会将“未跟踪”文件添加到您的提交中 - 这意味着过去不受 git 控制的文件。
添加文件后,您可以git status
再次运行,您将看到“暂存以供提交”的文件列表。一旦你有了这个,你可以添加你的提交:
git commit -m "Huh"
现在,当您执行时,git status
您应该会看到“nothing to commit”消息。
推荐阅读
- python - 将行分成两列并保持其他列相同
- flutter - 替换页面后如何获得弹出结果?
- python - 也可以从任务管理器打开应用程序 excel 保存和关闭
- google-text-to-speech - 生成音频时可以包含音乐背景吗?
- angular - 如何在我的 Angular 项目中修复此 Get 请求中的此错误?
- python-3.x - django 模板标签 url 仅在最后一个空 url 模式时有效
- react-native - 当手指在特定位置滑动时触发按钮反应原生
- javascript - 如何将 w2ui 网格列宽初始化为内容?
- java - 我有一个带有 RuntimeException “应该没有参数”的 Junit4 测试,用于参数化测试
- python - Python.NET & TensorFlow & CUDA:无法加载动态库 'cublas64_11.dll'