Skip to content
Lucas Holt edited this page Apr 11, 2023 · 9 revisions

MidnightBSD moved to git in early 2020 for all development.

Checkout MidnightBSD

Read Only use

git clone https://github.com/MidnightBSD/src.git

(also works with svn or svnlite with github)

Developer

git clone [email protected]:MidnightBSD/src.git

Checkout mports

git clone https://github.com/MidnightBSD/mports.git

Developer

git clone [email protected]:MidnightBSD/mports.git

Setup Author

There are at least two methods here. The first is to use git config and the second is environment variables.

Using git config

git config --global user.name "John Doe"
git config --global user.email "[email protected]"

If you only want it for the current repo, don't use the --global

If you screw up a commit and need to fix it before setting this

git commit --amend --author="John Doe <[email protected]>"

Environment Variable

It's global and overrides any git config settings, at least in some versions of git.

export GIT_AUTHOR_NAME="Midnight the Cat"
export GIT_AUTHOR_EMAIL="midnight@localhost"

Checkout Branches

(assuming you've cloned and are in the directory)

Change to the stable 1.2 branch git checkout stable/1.2

See what branch you're on and other local branches as well as the most recent commit on them git branch -v

View remote branches

(assumes remote is called origin) git remote show origin

Interactive Rebase

It's best to read up on this one. https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages

This will walk you through each commit starting at the one you specified, which should be the last "good" commit.

git rebase -i -p 0ad14ff3

For example, if you want to fix author info: git commit --amend --author="John Doe <[email protected]>" --no-edit

git rebase --continue

Renaming Remote Branches

rename locally

git checkout old-branch
git branch -m new-name

verify name

git branch -a

rename remote (assumes previous steps for local)

git push origin --delete old-name 
git push origin -u new-name

Delete remote branches

git push remote_name -d remote_branch_name

Workarounds

If you start seeing ESC[ type escape sequences with git commands, you likely need to fix your pager.

One solution is

git config --global core.pager "less -R"

Patch for a specific commit

git format-patch -1 <sha>

Vendor Branches

src committers need to make vendor branches to track third-party code.

Creating a new vendor branch

The first option starts with creating a new directory and git repo outside the src directory.

cd /some/where
mkdir foo
cd foo
git init
git checkout -b vendor/foo

The second option instead is to just run

git checkout --orphan vendor/foo

Commit the code

cp -r ~/foo/* .
git add *
git commit -m "Import foo 1.0"

Import it into src repo

cd /usr/src
git remote add foo /some/where/foo
git fetch foo vendor/foo

Tag and push

git worktree add ../foo vendor/foo
cd ../foo
git tag --annotate vendor/foo/1.0
git show
git push --follow-tags origin vendor/foo

merge it

cd ../src
git subtree add -P contrib/foo vendor/foo
git show
git commit --amend
git push origin

Update existing vendor branch

git worktree add ../foo vendor/foo
cd ../foo
rsync -va --del --exclude=".git" ~/git/foo .
git add -A
git status
git diff --staged
git commit -m "Vendor import of foo 1.0"

Tag

git tag -a vendor/foo/1.0

git push --follow-tags origin vendor/foo

Merge into master

cd ../src
git subtree merge -P contrib/foo vendor/foo

Exit the worktree

git worktree remove foo