tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Slightly off topic, question about git





On Mon, Jun 6, 2022 at 8:24 AM Mouse <mouse%rodents-montreal.org@localhost> wrote:
> [...], I have a question about git, [...]

I'm not an _expert_ on git, but I have been using it for close on a
decade now and have developed a certain amount of expertise.

> 1.  In CVS, I can do something like:
> cvs log sys/dev/pci/if_bge.c
> and be given a complete history of the changes to that file, as well
> as a list of all the branches that file participates in and which
> versions apply to each branch.

git log -- sys/dev/pci/if_bge.c

> And, I can do this without having to download all of the history of
> that file onto my local storage.

That, you will not find with git.  git does, somewhat, support what is
called a shallow clone of a repo, but it is limited by restricting it
to recent commits, not by restricting it to only certain portions of
the tree.  I'm not aware of any way to do the latter.


I'm not a git expert or anything but here are some examples of restricting things and savings disk space/memory

git clone --single-branch --depth 1 --branch netbsd-9 git%github.com@localhost:NetBSD/src.git
Cloning into 'src'...
remote: Enumerating objects: 182228, done.
remote: Counting objects: 100% (182228/182228), done.
remote: Compressing objects: 100% (146504/146504), done.
remote: Total 182228 (delta 47394), reused 115949 (delta 29844), pack-reused 0
Receiving objects: 100% (182228/182228), 401.74 MiB | 8.93 MiB/s, done.
Resolving deltas: 100% (47394/47394), done.
Updating files: 100% (177533/177533), done.

src $ git branch
* netbsd-9
src $ du -sh .git/
428M    .git/
src $ git log

----
git clone --single-branch --depth 1 --branch netbsd-9 --no-checkout git%github.com@localhost:NetBSD/src.git

...
cd src
git sparse-checkout init --cone
git sparse-checkout set sys

src $ git checkout
Updating files: 100% (29032/29032), done.
Your branch is up to date with 'origin/netbsd-9'.
src $ ls -l
total 392
-rw-r--r--   1 msporleder  wheel  53770 Jun  6 14:04 BUILDING
-rw-r--r--   1 msporleder  wheel  16543 Jun  6 14:04 Makefile
-rw-r--r--   1 msporleder  wheel    355 Jun  6 14:04 Makefile.inc
-rw-r--r--   1 msporleder  wheel   1751 Jun  6 14:04 README.md
-rw-r--r--   1 msporleder  wheel  34634 Jun  6 14:04 UPDATING
-rwxr-xr-x   1 msporleder  wheel  70768 Jun  6 14:04 build.sh
drwxr-xr-x  36 msporleder  wheel   1024 Jun  6 14:05 sys







Home | Main Index | Thread Index | Old Index