【问题标题】:Is it possible to switch between GIT commits?是否可以在 GIT 提交之间切换?
【发布时间】:2014-03-12 15:16:51
【问题描述】:

我目前正在尝试了解 git,并且到目前为止已对项目进行了 2 项更改:

oshiro@debian:/var/www$ git log

commit 4fd249jf039jf49rj905482h794g805h4g53943h
Author: oshiro <oshiro@mail.com>
Date:   Wed Mar 12 15:07:00 2014 +0000

    removed junk from initial version

commit 39fru438439fj3498521490u53945u854u3084ut        
Author: oshiro <oshiro@mail.com>
Date:   Wed Mar 12 14:53:40 2014 +0000

    initial messy project version

oshiro@debian:/var/www$ 

我可以在最初的混乱项目版本和从初始版本中删除的垃圾之间切换吗?

【问题讨论】:

  • git checkout 39fru438439fj3498521490u53945u854u3084ut 或任何提交。

标签: git


【解决方案1】:

如果你想创建一个没有提交“从初始版本中删除垃圾”的分支,你可以这样做

git checkout 39fru438439fj3498521490u53945u854u3084ut

如果你想从这个提交中创建一个命名分支,你可以这样做

git checkout -b new_branch 39fru438439fj3498521490u53945u854u3084ut

【讨论】:

    【解决方案2】:

    只需签出您想要的任何提交。

    git checkout 'commit'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-20
      • 2019-02-22
      • 2011-04-15
      • 2016-02-08
      • 1970-01-01
      • 2020-09-04
      • 2018-04-07
      • 1970-01-01
      相关资源
      最近更新 更多