From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.153 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796073735; b=LrU8+R709sB2O0d4Ers761odjuCB1lEfORFK5p+lep4ozGNmu0Bqiv0BOZKYw/eWu+LJ wIb1Mc2MERoEbwxLnJ5vQNSScx7sRdOH4twQrkEDXXeM8Ojaq8wYtN5INk1QZfa1S7NQg IqgBsrEaQnNKWdMIkatx6+lSD/OiDconVhk0JA20GOBXnXk8/eqng7pxaYIAYGXGizqep rpdIniqxhjThsXW3Q79U2wemECMQp5pk03FVaOlIfgFBWSNkpsjyqioDR7n/6u38+1MKg IZY0Gkh39Xa/6ncPuHpQ7Mf0mwEMV9UuYu5hvZnLmpLeW69KQyw6EVF3GPJJKbTGDeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796073735; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: User-Agent:MIME-Version:Content-Type; bh=65lt6admV4nNd142xmFlJpHei1xnb74PNjXGYGBRMmY=; b=OnUMS7c3O2+rNJpDkkr6BRR91yXHWQlVSIApvAnfxpejK11vzmElrWhA9xuQsGIV1Brr qAOnpmuSMzo3jfh+2JvyJcMMaqqmDcm/eiqTNN7oNzFW9v8OhZDcq0Z4ADZVjKuX/4dIM AfVgZUoRhr5AOUhg2XtoRrg4M09ULIU92tBYAy+HWA6ZTJw79rK3fM5wW8W+q1N9ue3Lg OCJdlrPseO/Klv8oimGQ76HEzC/jEISCrvnETBOi4oTO7ZmCuzVeDpKquTOb8wDCW9FfX kXArBWdAK9IiE8Rs9o2lBaVpMKEHTbtl76Rm1RX+lNZzomXGvqIPGpHM9Yql+6FhfPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b="jzYdN/3r"; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=cXUfWAcR; arc=none smtp.remote-ip=202.12.124.153 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA3ED606A31A for ; Mon, 30 Nov 2026 21:22:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AA3ED606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=jzYdN/3r; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=cXUfWAcR Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id A494C7A03BD for ; Mon, 30 Nov 2026 16:22:13 -0500 (EST) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-05.internal (MEProxy); Mon, 30 Nov 2026 16:22:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1796073733; x=1796160133; bh=65lt6admV4 nNd142xmFlJpHei1xnb74PNjXGYGBRMmY=; b=jzYdN/3rwywxcdb7Ali2mbCh0e pgjPLG2SiwLoh7OxGmOYMqr+N/4DA5U5elFdUDMyYdiHYclyYrXqg4XTcwXEPW7V P3BL85xarlEYKR1i/hvwPnzaI4H+YKtl8qqSzmb4StZLNR99vGMuipkgtq6cTM6e 6iNFIUIc95gSZxFC9HPF0SXCtOICrdcS9xWDgcs5jd+5QF8iNTi0Rp1jWcKeSuJC bzykOp+7uHm0dw2F5UHDWn44tS3zS5oicXSkdfs7WMOfMWKN4qDHw6wM53tgG7Ln Yp9m89TjD6O1yqfKJDWBzb/o/7yoQM4/GZm+RDVxju5gZ64B3ZBiDJG6/TxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796073733; x=1796160133; bh=65lt6admV4nNd142xmFlJpHei1xnb74PNjX GYGBRMmY=; b=cXUfWAcRtZTnNiZpClSFn7PhvKl2zC0Nxd0u1l3z2v0Q1TnJFhB Is0YAiMErmqqUnR4Uu7z8umcOpq0B2fyEljjnGeGZbwMTmG/dZrrlmV4lJoKy1ek mGbEUEQVQPsVv692+iN6jfWqS5SYD3+2mcrL+oUDMEihL9D5E7HYqg/cRQBOgxWQ zMAPKNTMMoGIpZR5FroVWje0bYTSua9mQwKZmkRk0xQcxjEnTH9MpSzZd/PLw76w eefQUICcBkBbHOh4LDYaxYKIyKI7odMFF3lkEqQXjlrFgBP+waudCQNwaKLzW7un W8CBMQuf5chTu/J11+EBI3h+bHWh6L0lo1A== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pobox.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796073733; d=pobox.com; mf=PGdpdHN0ZXJAcG9ib3guY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:Z6HlOjRaRGqh0EDsdtHklcE8ApfY4Qnjimh+fYPZZLWlYmr PLRy/paGtATo7mpZL7sr0R3tR3wsozfe5+mb0SNcU+QKJZonl4Zw3zDIpZoqdgyO sHMIZ06tbYW919stQee439/XavfgjJIZfo32I8OC3CK4cxUr+44mLCxQmKlGBg7F DfvuNmTzpshUVXjrTdt02HvZKx93pq590wnZstPpqQW9WmT89FU/Cy4M8ZGwbhSw Xi/Yinn4SHBRWQ/W34Zasfdhjy60wLgETkvrZ+a+AOuZ8ChutgNPyKSf1kSRPx7z BEUKqDYEUT7YkfhGIzWh+tmTrOfhRlV6lnlqNYg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to,user-agent; Message-Instance: m=1; h=sha256:Su0nGrTKh9JiYSykINGLY422Jo+gPbzMkU6r1Y+/yg0=:XYxQ92+i5XjMPZb/nTbi6EaOfZ6yk0PuWIGrTQz7PvE=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGFDvlzUq2/L0WS6lqtD6B8YgniW2LYzkD3wuQu3+YLdC+i9tnJBC2DysmEXaXOOM EkJ1R42LqURUTQh/XW20QzGgNXxbgu/Xm+l7dk4UVRdFhaYfc1EUlOp0S/b3kWzLmHiRNm 4FAD7ZEmsDF0tyONjA00TFUTsXJ2Rb1fmF9zso4EOlaRqJr9ZsiZYNyx++ci1bQIuXrWk3 rCBXUaPoVMp/+QktK794lFtoWtU73aRe1VuDPBj0dBogWyQhpfOsxf2ysSMqC5bwZwqtCn IRbbUHboyD9IZ7t5l3nDAOU0zb/z4Ox6bE1nGWSj8vke9j0ukB6gdjfKmlivRa4TBIa3Hh /6grU24k4YySYZcNHnxlZJn9NdKINXX8bczX0yqj3MjpEsvq4tfgwAaEDNdh1CY/x3OIQa naL/2VsviILxrblHpv4KXMYcIS0zUkzrhyPL5QOrlQ5orCH6ur5lYHKTEaKpBkbMiLMhAV pz1bpmdRsUwliyvYwMSHnlinvI8jyuVJFURomSmOcrQnOvGzhq7DjDG9CuZJQQuPBWv2ph rVA0yXhg0kT4v8wuCpGFlhLXva0o3uVkttTV03qZkVTN2uDybmGZjJ7N93wqxvflXSnnGx u/T5c6YLwnvSkaK2T7DakbSBYQ3eUNSN8JiKk7mZtK59CSsV6hBYwwsI5Zhw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Nov 2026 16:22:12 -0500 (EST) From: Junio C Hamano To: "D. Ben Knoble" Cc: Steven Rostedt , Mirko Faina , git@vger.kernel.org Subject: Re: Prevent git reset --hard from losing data In-Reply-To: (D. Ben Knoble's message of "Mon, 30 Nov 2026 09:54:55 -0500") References: <20261120145444.13061eb7@gandalf.local.home> <20261123160009.61bf0bce@gandalf.local.home> Date: Mon, 30 Nov 2026 13:22:11 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain "D. Ben Knoble" writes: >> I just wanted to update one of my branches to one of my devel branches and >> did a git reset without the hard and at the end it gives me: > > [a large diff between HEAD and working tree] > > Here a simple "git restore ." would restore the working tree to match > the index (which should be equivalent to HEAD), right? Everything in the current index, yes, but I am not sure about the paths that got removed from the index (i.e., the commit you resetted to did not have them, but the index and the working tree before you ran "git reset" did have them). Wouldn't they become untracked cruft left in the working tree? When you try to the "git checkout" back to the state that have them tracked, the command may refuse to overwrite them. If you said 'git reset $another' by mistake, when you wanted to say 'git reset --hard $another', which actually have happened to me a few times, $ git reset @{1} ;# go back to where I was $ git reset --hard @{1} ;# go back there again, with --hard is how I would recover. With the first "reset @{1}" the index would match what is in the working tree (so you resurrect the index entries for the leftover files in the working tree), and then "reset --hard @{1}" goes back to where you wanted to go, but with "--hard", the paths that were in the commit you were on but not in the commit you are moving to now gets removed correctly.