From owner-freebsd-git@freebsd.org Thu Nov 19 13:03:52 2020 Return-Path: Delivered-To: freebsd-git@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C8E0546B41B for ; Thu, 19 Nov 2020 13:03:52 +0000 (UTC) (envelope-from uqs@freebsd.org) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2a05:fc87:1:5::15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "www.spoerlein.net", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcKcm1Dn8z4dxf for ; Thu, 19 Nov 2020 13:03:51 +0000 (UTC) (envelope-from uqs@freebsd.org) Received: from localhost (acme.spoerlein.net [IPv6:2a05:fc87:1:5:0:0:0:15]) by acme.spoerlein.net (8.16.1/8.15.2) with ESMTPS id 0AJD3fMt085225 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 19 Nov 2020 14:03:42 +0100 (CET) (envelope-from uqs@freebsd.org) Date: Thu, 19 Nov 2020 14:03:41 +0100 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Marc Branchaud Cc: Dan Langille , freebsd-git@freebsd.org Subject: Re: checking out a commits on port quarterly branch Message-ID: References: <5E8AEDD5-327A-46A0-A186-EDBC616A9F89@langille.org> <47863540-fbe8-bd1e-25bd-da17f4ca5d06@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <47863540-fbe8-bd1e-25bd-da17f4ca5d06@gmail.com> User-Agent: Mutt/2.0.1 (2020-11-14) X-Rspamd-Queue-Id: 4CcKcm1Dn8z4dxf X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:39540, ipnet:2a05:fc87::/32, country:CH] X-BeenThere: freebsd-git@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion of git use in the FreeBSD project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 13:03:52 -0000 Just to add, losing work in git is actually very hard. While it's true that committing to a detached head doesn't track the new commits in a permanent way, you can actually use `git reflog` to see everything that you checked out for the last 90d or so. To me, resetting the index is a more scary proposition, because I've still not wrapped my head around how that works and what --hard does, etc. Cheers Uli On Wed, 2020-11-18 at 18:42:09 -0500, Marc Branchaud wrote: >Hi Dan, > >You're doing it right, assuming that you're not going to be adding any >new work atop that checked-out commit. Your working copy does indeed >reflect the code as of commit 46433baae934d92698422495b72f811839caa1a9. > >I've found that the best way to think of git branches is simply as a >label for a particular commit SHA ID. Git has other ways of labeling a >commit (notably tags, and you can actually create your own, separate >sets of labels if you like). Git internally calls these labels "refs". > The special thing about a branch "ref" is that, when you have the >branch checked-out and create a new commit, git automatically updates >the branch's label to refer to the new commit. > >But you can also checkout a commit using its SHA ID, as you did. In >this case you are not using a branch, so git is warning you that it is >not tracking a name for any new commits you might create. Git still >lets you do anything you want in this "detached" state, with the caveat >that if you make new commits then it's up to you to figure out how to >keep track of them (SHA IDs being a bit hard to memorize). BTW, >checking out a tag also puts git into the "detached" state, because tags >are considered static and so they do not get automatically updated when >you add new commits. > >For regular development it's important to understand when you're in the >"detached" state, because it's easy to lose your work. Hence the big >warning message (which you can disable). But if you're just looking to >build the code at a particular commit, you're fine being "detached" from >any actual branch. > > M. > > >On 2020-11-18 5:30 p.m., Dan Langille wrote: >> When FreshPorts processes a commit, it needs a working copy of the repo as it was at the time of that commit. >> >> I have this working on head. I am trying to figure out how to do that when the commit is on a branch. >> >> To get a copy of the branch, I do: >> >> $ git checkout branches/2020Q4 >> $ git branch >> branches/2020Q2 >> branches/2020Q3 >> * branches/2020Q4 >> master >> >> Next, I want the tree as it existed at commit 46433baae934d92698422495b72f811839caa1a9 >> >> i.e. https://github.com/freebsd/freebsd-ports/commit/46433baae934d92698422495b72f811839caa1a9 >> >> My first attempt is >> >> $ git checkout 46433baae934d92698422495b72f811839caa1a9 >> Note: switching to '46433baae934d92698422495b72f811839caa1a9'. >> >> You are in 'detached HEAD' state. You can look around, make experimental >> changes and commit them, and you can discard any commits you make in this >> state without impacting any branches by switching back to a branch. >> >> If you want to create a new branch to retain commits you create, you may >> do so (now or later) by using -c with the switch command. Example: >> >> git switch -c >> >> Or undo this operation with: >> >> git switch - >> >> Turn off this advice by setting config variable advice.detachedHead to false >> >> HEAD is now at 46433baae934 MFH: r555565 >> >> That "MFH: r555565' message indicates that I am at the right commit. >> >> Is this a concern? >> >> $ git branch >> * (HEAD detached at 46433baae934) >> branches/2020Q2 >> branches/2020Q3 >> branches/2020Q4 >> master >> >> >> Am I doing this right? >> >> Thank you >> >> >_______________________________________________ >freebsd-git@freebsd.org mailing list >https://lists.freebsd.org/mailman/listinfo/freebsd-git >To unsubscribe, send any mail to "freebsd-git-unsubscribe@freebsd.org"