Reputation: 31
How to perform a git reset --hard
- by reading the commit hash from a file
Upvotes: 1
Views: 2626
Reputation: 29598
I'm assuming you're on Windows because of the TortoiseGit in the title.
Given a hash.txt with just "a7abda785" as its contents (or any hash for that matter), you can run this batch file to do git reset
using the hash from hash.txt:
@echo off
set /p HASH= < hash.txt
git reset --hard %HASH%
The /p
sets the variable by prompting the user for input, which we automatically provide by redirecting the contents of the file.
With this script, you can include:
git reset
if the hash is invalid (i.e. empty)Upvotes: 1
Reputation: 3111
Open Reset
dialog
Reset Hard [sha-1]
Refresh the Log dialog
BTW, if the file is .git/FETCH_HEAD
, you can just view that commit by this way:
Upvotes: 2