From owner-freebsd-git@freebsd.org Thu Jan 28 06:33:28 2021 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 162D44F9ABD for ; Thu, 28 Jan 2021 06:33:28 +0000 (UTC) (envelope-from freebsd-git@dino.sk) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DR9dz69vKz4gVh; Thu, 28 Jan 2021 06:33:27 +0000 (UTC) (envelope-from freebsd-git@dino.sk) Received: from zeta.dino.sk (fw3.dino.sk [84.245.95.254]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Thu, 28 Jan 2021 07:33:17 +0100 id 003E8C74.60125AAD.00016050 Date: Thu, 28 Jan 2021 07:33:15 +0100 From: Milan Obuch To: Mark Millard Cc: Ulrich =?UTF-8?B?U3DDtnJsZWlu?= , freebsd-git@freebsd.org Subject: Re: git setup/usage question Message-ID: <20210128073315.44377b29@zeta.dino.sk> In-Reply-To: <00F58366-4178-458E-8865-E1A2E5324EB4@yahoo.com> References: <20210126151017.4a9dd711@zeta.dino.sk> <00F58366-4178-458E-8865-E1A2E5324EB4@yahoo.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i386-portbld-freebsd11.4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4DR9dz69vKz4gVh X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] 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, 28 Jan 2021 06:33:28 -0000 On Wed, 27 Jan 2021 15:29:38 -0800, Mark Millard wrote: > On 2021-Jan-27, at 12:55, Ulrich Sp=C3=B6rlein wrote: >=20 > > On Tue, 2021-01-26 at 15:10:17 +0100, Milan Obuch wrote: =20 > >> . . . > >> # git -C /mnt/src/.git fetch > >> remote: Enumerating objects: 5, done. > >> remote: Counting objects: 100% (5/5), done. > >> remote: Compressing objects: 100% (5/5), done. > >> remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 > >> Unpacking objects: 100% (5/5), 42.60 KiB | 484.00 KiB/s, done. > >> From https://git.freebsd.org/src > >> * branch HEAD -> FETCH_HEAD > >>=20 > >> This time there is something new... I need a merge now. > >>=20 > >> # git -C /mnt/src/.git merge > >> fatal: this operation must be run in a work tree =20 > >=20 > > No, you don't want to merge. Why would you merge? You want to run > > `git pull`, that will pull the updates from the remote refs into > > your local refs. =20 >=20 > QUOTE from https://git-scm.com/docs/git-pull : > git pull is shorthand for git fetch followed by git merge FETCH_HEAD > END QUOTE (other wording for the likes of --rebase not quoted) >=20 > Looks to me like he tried to do something like what > git pull does, but in two explicit, separate steps: > git fetch and git merge. > Exactly. And the behaviour is also verified - for one worktree, what does git pull is exactly the same as git fetch followed by git merge. I have currently three repository copies with various setup and various steps used to create them, but what I do (pull vs. fetch + merge) is consistently the same, when done at the same time. > >> I am a bit stuck now. What does it mean 'being in a work tree'? > >> Doing 'cd /mnt/src/main' or similar before git command does not > >> change anything. I read 'man git-merge' but still no clue. It must > >> be something simple, I just do not see it. > >>=20 > >> Also, > >>=20 > >> # git -C /mnt/src/.git log > >>=20 > >> does not show new commit yet. If I do 'git pull --ff-only' command > >> (with another git repository, created exactly the way mentioned in > >> primer) at the same time, I see new commit in log output. It looks > >> like log is updated on merge, not fetch, judging from my previous > >> litlle bit of experience with git, so this maybe should be > >> expected, I just do not know. =20 > >=20 > > No, the log isn't updated on `merge` (probably just sloppy > > wording), what your log does is show the log of the local ref and > > you haven't pulled anything into it yet. If you had done git log > > refs/remotes/freebsd/main (or whatever that is on a bare repo), > > then you'd have seen the updates. =20 >=20 > He did both the git fetch and a git merge (but not a fast forward > merge). Again, exactly. Re: fast forward merge - from --ff option description in git-merge it looks to me it is actually not important if I am following branch with no other actions on it, i. e. with no local changes. At least it works this way according to my (gained up to now, still relatively limited) experience. > But he had cloned with --bare and: >=20 > QUOTE from https://git-scm.com/docs/git-clone : > --bare > . . . Also the branch heads at the remote are copied directly to > corresponding local branch heads, without mapping them to > refs/remotes/origin/ . When this option is used, neither > remote-tracking branches nor the related configuration variables > are created. > END QUOTE >=20 > So things seem to be odd compared to the normal expected > type of configuration for FreeBSD. With some tweaks, things are perfectly working now, for me everything is perfectly logical. Actually I would describe it as expected for using multiple worktrees, not vasting space (keeping multiple full repositories) and time (updating multiple repositories). > >> So the big question - did I the right steps to achieve what I want, > >> descibed in the beginning of this mail? Is this way OK to use, or > >> should I use some other way to achieve this? =20 > >=20 > > Yep, all looks perfectly fine, except you need to run git pull to > > bring in remote changes. So usually `git fetch` to update your copy > > of the remote refs, then `git pull --rebase` to bring in the > > changes into your local copy of the ref _and_ update the checked > > out copy. > >=20 > > You might have to tweak all that a bit though for the bare repo > > case with worktrees.=20 >=20 > It looks to me like he is using a configuration (--bare) > outside the range FreeBSD is intending to deal with and > so he needs his own fairly-unique procedures for using > git for FreeBSD activity. > I think exactly the opposite - the way I did it looks (at least to me) as a natural way extending simple case described in Warner's Git Primer if one desires to track multiple branches for whatever reason. I am still fine tuning my setup and gaining more experiences with git, but in my oppinion (and others as well, I found some articles mentioning exactly the same) worktrees are really powerfull tool for a developer, which, when used with some thinking and carefully, could make one's development much easier. I plan to document my setup soon with simple steps to re-create it and some explanations as well. I do not still understand everything in detail, but what I tried makes me confident I can use git this way effectively. Regards, Milan