Git,是否可以保留未来的变化?

时间:2016-07-15 10:12:03

标签: git

我有一些代码应该暂时还原,但我稍后会需要它。是否有可能恢复但保留更改的类以供将来使用?

编辑: 我知道,可以将它们移到单独的更改列表中并在提交时忽略。但那不是我需要的。我实际上需要保留两个版本的文件。

谢谢。

2 个答案:

答案 0 :(得分:2)

当然这是可行的。

  1. 首先恢复为您希望保留的提交
  2. 根据还原的提交
  3. 创建分支
  4. 回到头部
  5. 现在你们两个都有!

    具体做法是:

    git checkout -b 0x1234 // get the old code and create a new branch based on it
    git checkout master head // head is the tip of your current master
    

答案 1 :(得分:0)

您想使用git stash。不,真的,我知道你已经接受了另一个答案,但请帮自己一个忙,试试git help stash;您99%的时间使用的两个命令是git stashgit stash pop