-
Notifications
You must be signed in to change notification settings - Fork 85
Repository
If you are tracking any remote branches, first fetch updates from those remotes.
git -C / fetch --all
You can then merge any updates to tracked branches.
git -C / merge
Create a new staging directory in which to update the software contents. If you are adding new software, choose a new branch name, otherwise, use the existing branch name.
git -C / worktree add --detach --no-checkout $PWD/stage
git -C stage symbolic-ref HEAD refs/heads/somepackage
In this worktree, install the new package contents to the staging directory and commit the result.
make install DESTDIR=$PWD/stage
git -C stage add .
git -C stage commit -m 'somepackage X.Y'
To delete a package instead, just commit the empty contents.
git -C stage commit -m 'delete somepackage'
If this is a new branch, add it to the list of branches merged to master by default.
git -C / config --add branch.master.merge somepackage
Finally, merge the software into / (--allow-unrelated
is only necessary
if this is a new branch).
git -C / merge --allow-unrelated
If you recompile your system with different flags or compiler, or just gradually update packages over time, you may end up with a large root repository. To fix this, you can prune the history by making a new commit with the same tree as master, but with the branches we care about as direct parents. Then, mark the commits of those branches as shallow, and prune everything else.
cd /
branches=$(git config --get-all branch.master.merge)
commit=$(git commit-tree -m 'Prune tree' $(printf '-p %s ' $branches) 'HEAD^{tree}')
git reset $commit
git show-ref -s $branches > .git/shallow
git reflog expire --expire-unreachable=all --all
git gc --prune=all --aggressive