私の実験では、機能的な違いを見つけることができませんでした
git reset --hard
と
git reset --merge
使用説明書にもヒントはありません
--hard reset HEAD, index and working tree
--merge reset HEAD, index and working tree
私はこのオプションを定期的に使用している--hard
ので、その仕組みを理解しています。--merge
と--hard
オプションの違いは何ですか?
乾杯、 オリー
おそらくここで例が役立つでしょう。次のシーケンスを使用しましょう。
cd git_repo
touch file_one
git add file_one
git commit -m "commit one" # sha1 of 123abc
echo "one" >> ./file_one
git commit -a -m "commit two" # sha1 of 234bcd
echo "two" >> ./file_one
git add . # populate index with a change
echo "three" >> ./file_one # populate working area with a change
今私が試してみると
git reset --merge 123abc
私は得る
error: Entry 'file_one' not uptodate. Cannot merge.
fatal: Could not reset index file to revision '123abc'
file_one の作業領域とインデックスの両方に変更があるためです。
これを改善するために私は
git add .
git reset --merge 123abc
今回は動作しますが、 と同じ結果が得られgit reset --hard
ます。最初のコミット後と同様に、インデックスは空で、作業領域は空で、file_one は空です。
誰かが違いを説明する手順を思い付くことができますか?