TortoiseGit - 如何执行git reset --hard <by reading =“”the =“”commit =“”hash =“”from =“”a =“”file =“”>

时间:2017-08-16 11:21:05

标签: git tortoisegit

如何执行git reset --hard - 通过从文件中读取提交哈希

2 个答案:

答案 0 :(得分:1)

我假设你因为标题中的TortoiseGit而在Windows上。

给出 hash.txt 只需&#34; a7abda785&#34;作为其内容(或任何哈希值),您可以使用 hash.txt 中的哈希运行此批处理文件来执行git reset

@echo off

set /p HASH= < hash.txt
git reset --hard %HASH%

我们通过重定向文件内容自动提供的/p sets the variable by prompting the user for input

使用此脚本,您可以包括:

  1. 将另一个哈希值放入 hash.txt
    (我假设您正在使用其他命令或脚本将哈希写入文本文件)
  2. 如果散列无效(即空),则跳过git reset

答案 1 :(得分:1)

  1. 打开Reset对话框

    • 打开日志消息对话框
    • 右键点击任意提交
    • 点击Reset "xxx" to this...
      enter image description here
  2. 重置硬[sha-1]

    • 复制文件中的sha-1值
    • 将其粘贴到提交文本
    • 点击Hard选项
    • OK按钮
      enter image description here
  3. 刷新日志对话框

  4. 顺便说一句,如果文件是.git/FETCH_HEAD,你可以通过这种方式查看提交:

    enter image description here

相关问题