git - Resetting a new file in staging area to working directory in Git
问题描述
In Git I have checked out a new branch branch b
and made multiple changes including edits, new files, folders etc. I need to revert back to an old branch branch a
to make changes, so I want to stash all changes made in branch b
. However I have some untracked files and folder in branch b
so if I revert back to branch a
, they follow as untracked files.
I attempted to add and then reset these untracked files with the intention of them moving to the working directory, but they revertedback to an untracked file (no surprise).
Question
How do I add these untracked files in branch b
to the working directory ready to be stashed? (without committing)
解决方案
您可能有兴趣使用
git add --intend-to-add
开始跟踪文件而不真正添加/提交它们。
从手册:
-N, --intent-to-add
仅记录稍后将添加路径的事实。路径的条目被放置在没有内容的索引中。除其他外,这对于使用 git diff 显示此类文件的未暂存内容并使用 git commit -a 提交它们很有用。
推荐阅读
- java - JavaEE:尝试公开我的 Rest Web 服务时出现 Nullpointer
- javascript - Firestore,使用自定义键检索字段时出现问题
- reinforcement-learning - NameError:名称“base”未定义 OpenAI Gym
- java - 相同的二叉树练习给定两棵二叉树,如果它们相同则返回true
- react-native - 无法在 TouchableOpacity 中收听 onpress
- python - 在 Bokeh 中更新数据
- python - 在 Django 上使用 postcodes.io API
- css - 如何设置圆形 div 的样式?
- scala - sbt ThisBuild 范围是否有块语法?
- mysql - Hive,分区与未分区数据库所花费的时间