只用Git修改多个文件中的一个文件? [英] Stash only one file out of multiple files that have changed with Git?

查看:151
本文介绍了只用Git修改多个文件中的一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如评论中指出的那样,这将所有东西放入存储器中,不管是上演还是未上架。 - 保持索引仅在索引完成后离开索引。这会在您稍后弹出存储时导致合并冲突。

As noted in the comments, this puts everything into the stash, both staged and unstaged. The --keep-index just leaves the index alone after the stash is done. This can cause merge conflicts when you later pop the stash.

这会隐藏您之前未添加的所有内容。只需 git add 您想保留的东西,然后运行它。

This will stash everything that you haven't previously added. Just git add the things you want to keep, then run it.

git stash --keep-index

例如,如果您想将旧提交拆分为更多您可以使用以下过程:

For example, if you want to split an old commit into more than one changeset, you can use this procedure:


  1. git rebase -i< last good commit>

  2. 将一些更改标记为 edit

  3. git reset HEAD ^

  4. git add<要保留在这个变更中的文件>

  5. git stash --keep-index

  6. 不要忘记对 git add 进行任何修改。 git commit

  7. git stash pop

  8. 根据需要从#5重复。

  9. git rebase --continue

  1. git rebase -i <last good commit>
  2. Mark some changes as edit.
  3. git reset HEAD^
  4. git add <files you want to keep in this change>
  5. git stash --keep-index
  6. Fix things up as necessary. Don't forget to git add any changes.
  7. git commit
  8. git stash pop
  9. Repeat, from #5, as necessary.
  10. git rebase --continue

这篇关于只用Git修改多个文件中的一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆