Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2021 15:10:17 +0100
From:      Milan Obuch <freebsd-git@dino.sk>
To:        freebsd-git@freebsd.org
Subject:   git setup/usage question
Message-ID:  <20210126151017.4a9dd711@zeta.dino.sk>

next in thread | raw e-mail | index | archive | help
Hi,

I am working on new workflow setup after svn->git move. I did some
tests, starting with Warner's Hacking Blog at
http://bsdimp.blogspot.com/2020/10/freebsd-git-primer-for-users.html
and trying some suggestion and ideas taken from both this and current=20
mailing lists.

After gaining some bits of knowledge I am going to create something
more elaborate... for me.

What I would like to achieve:

- use one repository for all branches of interest and as working area
  too

- use separate working directory for each branch and working area
  (possibly multiple for multiple projects)

- track remote repository periodically and update working tree as
  needed (immediatelly after repository update or delayed when other
  work on a tree is being done at the moment).

I do not see in this anything special, just the primer mentioned above
handles basically just single working area case, which makes necessary
some switching (via checkout of different branch or somesuch).

So what I did:

# git clone --config remote.freebsd.fetch=3D'+refs/notes/*:refs/notes/*' --=
bare https://git.freebsd.org/src.git /mnt/src/.git
# git -C /mnt/src/.git worktree add /mnt/src/main main
# git -C /mnt/src/.git worktree add /mnt/src/13 stable/13
# git -C /mnt/src/.git worktree add /mnt/src/12 stable/12
# git -C /mnt/src/.git worktree add /mnt/src/11 stable/11

This way I have nice directory structure in /mnt/src, I can use
individual trees for either local null mount (for jails and similar
usage) or remote mount via nfs.

Look for status:

# git -C /mnt/src/.git worktree list
/mnt/src       (bare)
/mnt/src/11    09bdde595dd [stable/11]
/mnt/src/12    70cdab054c8 [stable/12]
/mnt/src/13    da2dfec8f75 [stable/13]
/mnt/src/main  25cdacf79b0 [main]

Nice! Clear, easy to understand. With some scripting, this could be
used to create id string for uname use (there is a thread about this on
arch list, this is something I need to think about especially for
remote building with sources mounted over nfs).

Now for updating, trying to fetch...

# git -C /mnt/src/.git fetch
=46rom https://git.freebsd.org/src
 * branch                    HEAD       -> FETCH_HEAD

This looks like there is nothing new to fetch at the moment. So waiting
a bit for new commit... waiting a bit more... trying again...

# 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.
=46rom https://git.freebsd.org/src
 * branch                    HEAD       -> FETCH_HEAD

This time there is something new... I need a merge now.

# git -C /mnt/src/.git merge
fatal: this operation must be run in a work tree

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.

Also,

# git -C /mnt/src/.git log

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.

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?

Regards,
Milan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210126151017.4a9dd711>