简体   繁体   English

理解使用本地仓库的“git checkout”

[英]Understanding of "git checkout" working with local repo

Let's assume I have a repo with file A.txt In remote repo with some commit-id this file contains string "Hello, World!"假设我有一个带有文件A.txt的 repo 在带有一些 commit-id 的远程 repo 中,这个文件包含字符串"Hello, World!" , but I want to clone it to my local machine and change this string to "Goodbye, World!" ,但我想将它克隆到我的本地计算机并将此字符串更改为"Goodbye, World!"

After git clone and git commit -m "Hello to Goodbye" I suddenly understand that this is not what I really want to do and trying to return my "Hello, World!"git clonegit commit -m "Hello to Goodbye"之后,我突然明白这不是我真正想做的,并试图返回我的"Hello, World!"

After doing git checkout -b stable_version <commit-id> I've got message about 'detached HEAD' state but there are no visible changes for A.txt file.在执行git checkout -b stable_version <commit-id>后,我收到有关“分离的 HEAD”state 的消息,但A.txt文件没有可见的更改。

So my question is what exactly should I do for rolling back to "Hello, World!"所以我的问题是我到底应该怎么做才能回滚到"Hello, World!" ? ?

try using git reset尝试使用git 重置

basically, enter the command git reset <Your Commit Id> , and it reverts back to the state before the commit was pushed基本上,输入命git reset <Your Commit Id> ,它会恢复到提交提交之前的 state

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

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