简体   繁体   English

Git Switch /结帐到此

[英]Git Switch/Checkout to this

I got myself in a mess and was wondering if you could help? 我陷入混乱,想知道您是否可以帮忙? There is probably a lot to it, so I was hoping to get the jist of what I need to do. 可能有很多事情,所以我希望了解我需要做的事情。

  • Rev 10 Does not compile correctly. 修订版10无法正确编译。
  • Rev 07 - Compiles correctly. 修订版07-正确编译。 I want to see what the difference between Rev 07 and Rev 08 to figure out what went wrong, then Integrate those changes into Rev 10. 我想看看Rev 07和Rev 08之间有什么区别,以找出出了什么问题,然后将这些更改集成到Rev 10中。
  • I need to verify commits 08 and 09 to see if they can compile or not. 我需要验证提交08和09,以查看它们是否可以编译。

This is what I think I need to do: 这是我想做的:

  1. I committed and pushed to save my changes. 我承诺并努力保存更改。 (Maybe I could have stashed the changes, but I don't know how to do that just yet.) (也许我可以隐瞒这些更改,但是我还不知道该怎么做。)
  2. Show Log 显示日志
  3. Switch/Check out to this (Rev 09) 切换/签到此(修订版09)
    • I don't want to create a branch. 我不想创建一个分支。 I just want to see if it compiles. 我只想看看它是否可以编译。 After I am done, I think I can just switch back to Rev 10 where I left off. 完成之后,我想我可以切换回我上次退出的Rev 10。 If my thinking is correct? 如果我的想法是正确的?
    • I wan't to select 'Overwrite working tree changes (force)', because I have already committed and pushed my working files. 我不会选择“覆盖工作树更改(强制)”,因为我已经提交并推送了我的工作文件。

Maybe I am wrong, but I don't think I have to create a branch every time I switch to a certain checkout. 也许我错了,但是我不认为每次切换到特定结帐时都必须创建一个分支。 All I want to do is verify the version compiles, then go back to where I left off. 我要做的就是验证版本是否可以编译,然后回到我停下来的地方。

PS I am trying to accomplish this with Windows GIT (if you couldn't tell). 附言:我正在尝试使用Windows GIT完成此操作(如果您不知道)。 I can get the jist of the Unix commands. 我可以得到Unix命令的精髓。

PSS If it isn't too much to ask, I was also thinking of making version 07 version 11. Get rid of the versions that don't compile, instead of making another "Working Branch". PSS如果要求不高,我也正在考虑制作07版的11版。摆脱那些无法编译的版本,而不是制作另一个“工作分支”。 What would be the correct way to do something like that. 做这样的事情的正确方法是什么? Extra thanks. 额外的感谢。

Thank you, 谢谢,

The trouble with checking out an earlier revision on its own is that it leaves your repo in “headless” mode. 自行检出较早版本的麻烦在于,它使您的存储库处于“无头”模式。 Unlike Subversion, Git doesn't remember which revision you are on if it isn't the tip of a branch. 与Subversion不同,如果它不是分支的顶端,那么Git不会记住您所使用的版本。

To properly keep track of things, you need to create a temporary branch at that earlier revision, eg: 为了正确跟踪事物,您需要在该早期版本中创建一个临时分支,例如:

git checkout -b temp_branch older_commit

This is easy to do, and you can always delete the branch later — remember that “ git-branch -d ” will only delete “fully-merged” branches, which such a temporary branch will be, so such a deletion will be quite safe. 这很容易做到,您以后可以随时删除该分支-请记住,“ git-branch -d ”将仅删除“完全合并”的分支,这样的临时分支将是这样,因此这样的删除将非常安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM