Some time ago I went through the process of switching to git from svn for updating /usr/src. I believe the newly git-created directories sat unused after completing that step those 20+ days ago, until I finally set aside the time to work on rebuilding my kernel and world again. I could have rebuilt and reinstalled my kernel and world right then but as it had been a while, I figured I should update my source. This is where I needed to research a bit more, the conversion method is readily available but mention of how to update was not and the commands are different than svn so I couldn't just use update as before.
First the conversion process which I did, the first step simply as a precaution. Copy your last /usr/src updated with svn to a backup directory:
cp -pRP /usr/src /usr/src-last_svn_update
Remove the directory and all contents then create a fresh directory. As /usr/src contains hidden files or directories, this may be more appropriate and an easier sure step. After, we still need the directory to use with git, so re-create it.
rm -rf /usr/src
mkdir /usr/src
Or just delete the /usr/src directory contents:
rm -rf /usr/src/*
Now that the way is prepared we can use git to get the source tree:
git clone -b master --single-branch --depth 1 git://github.com/freebsd/freebsd.git /usr/src
Github changed security in September 2021
git clone -b master --single-branch --depth 1 https://github.com/freebsd/freebsd.git /usr/src
Since I use the stable branch of version 12, below is how I obtain a specific branch, the manpage also indicates that --depth implies --single-branch, so we can omit that:
git clone -b stable/12 --depth 1 git://github.com/freebsd/freebsd.git /usr/src
git clone -b stable/12 --single-branch --depth 1 https://github.com/freebsd/freebsd.git /usr/src
The output is much less verbose than svn. We can follow the initial clone command with a few more which provide added detail and verification.
Cloning into '/usr/src'... remote: Enumerating objects: 84805, done. remote: Counting objects: 100% (84805/84805), done. remote: Compressing objects: 100% (71708/71708), done. remote: Total 84805 (delta 17987), reused 37808 (delta 10001), pack-reused 0 Receiving objects: 100% (84805/84805), 276.31 MiB | 10.02 MiB/s, done. Resolving deltas: 100% (17987/17987), done. Updating files: 100% (81378/81378), done.
Looking further into the insanely extensive git manpages, I find git reflog which appears to display in reverse order, the most recent action at the top.
94a5e942b (grafted, HEAD -> stable/12, origin/stable/12) HEAD@{0}: clone: from git://github.com/freebsd/freebsd.git
We can discover the config settings by typing the command below from /usr/src. Many of those settings are defaults and I must have setup my email address previously for git. I have used git sporadically for various things including my own repos of random projects so this is not a big surprise. The manpage for git-config lists a LOT more options.
user.email=username@mailsvc.com user.name=username filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true filter.lfs.clean=git-lfs clean -- %f core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=git://github.com/freebsd/freebsd.git remote.origin.fetch=+refs/heads/stable/12:refs/remotes/origin/stable/12 branch.stable/12.remote=origin branch.stable/12.merge=refs/heads/stable/12
The last thing I need to do is get the most recent updates, to
refresh my /usr/src, which if you read the initial paragraph is
really all I needed to do when I began this post, and all I will
need to do from now on. The first time updating /usr/src it
will be a two step process, the first line is only needed
once.
git config pull.rebase true
git pull
If you had not used that first line for your first update, git will give you a reminder as below.
hint: Pulling without specifying how to reconcile divergent branches is hint: discouraged. You can squelch this message by running one of the following hint: commands sometime before your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation.
Lets set the config and show the resulting config list change.
git config pull.rebase true
git config --list
user.email=username@mailsvc.com user.name=username filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true filter.lfs.clean=git-lfs clean -- %f core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=git://github.com/freebsd/freebsd.git remote.origin.fetch=+refs/heads/stable/12:refs/remotes/origin/stable/12 branch.stable/12.remote=origin branch.stable/12.merge=refs/heads/stable/12 pull.rebase=true
Now that the git variant on obtaining FreeBSD source is reasonably described, the post about updating kernel and world can be updated to match as well as the specifically related distilled page. Everything is setup, any further need to obtain source can be accomplished with one simple command:
git pull
No comments:
Post a Comment
Thank you for your interest!