Home > Mobile >  git checkout/reset commit_hash with link
git checkout/reset commit_hash with link

Time:01-17

For example next path: https://github.com/php/php-src/commit/7245bff300d3fa8bacbef7897ff080a6f1c23eba?w=1

git clone https://github.com/php-src/php-src.git

git reset --hard 7245bff300d3fa8bacbef7897ff080a6f1c23eba?w=1

fatal: Cannot do hard reset with paths.

Same problem for checkout

How can I do 'git reset' with commit_hash(7245bff300d3fa8bacbef7897ff080a6f1c23eba) with link='?w=1'

CodePudding user response:

You cannot do git reset --hard to a file, only to a commit:

git reset --hard 7245bff300d3fa8bacbef7897ff080a6f1c23eba

You can checkout a single file from a commit to the current worktree:

git checkout 7245bff300d3fa8bacbef7897ff080a6f1c23eba ext/spl/spl_directory.c
  • Related