dgit-maint-merge(7)
π dgit-maint-merge(7) β bestie's guide to the git-merge workflow π
okay so listen. this is the dgit manual page, specifically dgit-maint-merge(7), and it's the tutorial for package maintainers who want a workflow centered around git-merge(1). grab a drink, we're doing this together π«Ά
πΈ NAME πΈ
dgit β tutorial for package maintainers, using a workflow centered around git-merge(1)
β¨ INTRODUCTION β¨
This doc describes the pieces of a workflow for maintaining a non-native Debian package using dgit and git-debpush. And bestie, this workflow is opinionated, like it has THOUGHTS and it's not sorry:
- Git histories should be the non-linear histories produced by
git-merge(1), preserving all information about divergent development that was later brought together. all the receipts, preserved, periodt. π - Maintaining convenient and powerful git workflows takes priority over the usefulness of the raw Debian source package. The Debian archive is thought of as an output format. it's giving "the archive is just the export button", iykyk.
For example, we don't spend time curating a series of quilt patches. However, in straightforward cases, the information such a series would contain is readily available from dgit-repos.
- It is more important to have the Debian package's git history be a descendent of upstream's git history than to use exactly the
orig.tarthat upstream makes available for download. we're building on their tree, not swapping in their zip file π¦
ngl, this workflow is less suitable for some packages. When the Debian delta contains multiple pieces which interact, or which you aren't going to be able to upstream soon, it might be preferable to maintain the delta as a rebasing patch series. For such a workflow see for exampledgit-maint-debrebase(7)anddgit-maint-gbp(7).
π INITIAL DEBIANISATION π
This section explains how to start using this workflow with a new package. It should be skipped when converting an existing package to this workflow. (converting already-existings, we got u, scroll down bestie)
π When upstream tags releases in git
Suppose that the latest stable upstream release is 1.2.2, and this has been tagged '1.2.2' by upstream.
% git clone -oupstream https://some.upstream/foo.git
% cd foo
% git verify-tag 1.2.2
% git reset --hard 1.2.2
% git remote add -f origin salsa.debian.org:debian/foo.git
% git push --follow-tags -u origin master
That final command also has the effect of detaching your master branch from the upstream remote, so that git doesn't try to push anything there, or merge unreleased upstream commits. so like... it ghosts upstream on purpose, on purpose, for your own good π
Now go ahead and Debianise your package. Just make commits on the master branch, adding things in the debian/ directory. If you need to patch the upstream source, just make commits that change files outside of the debian/ directory. It is best to separate commits that touch debian/ from commits that touch upstream source, so that the latter can be cherry-picked by upstream. separate lanes bestie π£οΈβ¨
Note that there is no need to maintain a separate 'upstream' branch, unless you also happen to be involved in upstream development. We work with upstream tags rather than any branches, except when forwarding patches (see FORWARDING PATCHES UPSTREAM, below).
Finally, you need an orig tarball:
% git deborig
See git-deborig(1) if this fails.
This tarball is ephemeral and easily regenerated, so we don't commit it anywhere (e.g. with tools like pristine-tar(1)). it's not a keeper, it's a situationship π
π§ Verifying upstream's tarball releases
It can be a good idea to compare upstream's released tarballs with the release tags, at least for the first upload of the package. If they are different, you might need to add some additional steps to your debian/rules, such as running autotools.
A convenient way to perform this check is to import the tarball as described in the following section, using a different value for 'upstream-tag', and then use git-diff(1) to compare the imported tarball to the release tag. If they are the same, you can use upstream's tarball instead of running git-deborig(1).
π¦ Using untagged upstream commits
Sometimes upstream does not tag their releases, or you want to package an unreleased git snapshot. In such a case you can create your own upstream release tag, of the form upstream/ver, where ver is the upstream version you plan to put in debian/changelog. The upstream/ prefix ensures that your tag will not clash with any tags upstream later creates. π« (namespacing queen)
For example, suppose that the latest upstream release is 1.2.2 and you want to package git commit ab34c21 which was made on 2013-12-11. A common convention is to use the upstream version number 1.2.2+git20131211.ab34c21 and so you could use
% git tag -s upstream/1.2.2+git20131211.ab34c21 ab34c21
to obtain a release tag, and then proceed as above.
One can generate such a versioned tag using git show's --pretty option. e.g.:
% git tag -s upstream/$(git show --date=format:%Y%m%d --pretty=format:"1.2.2+git%cd.%h" --quiet upstream/main) upstream/main
π When upstream releases only tarballs
We need a virtual upstream branch with virtual release tags. gbp-import-orig(1) can manage this for us. To begin
% mkdir foo
% cd foo
% git init
Now create debian/gbp.conf:
[DEFAULT]
upstream-branch = upstream
debian-branch = master
upstream-tag = upstream/%(version)s
sign-tags = True
pristine-tar = False
pristine-tar-commit = False
[import-orig]
merge-mode = merge
merge = False
gbp-import-orig(1) requires a pre-existing upstream branch:
% git add debian/gbp.conf && git commit -m "create gbp.conf"
% git checkout --orphan upstream
% git rm -rf .
% git commit --allow-empty -m "initial, empty branch for upstream source"
% git checkout -f master
Then we can import the upstream version:
% gbp import-orig --merge --merge-mode=replace ../foo_1.2.2.orig.tar.xz
Our upstream branch cannot be pushed to dgit-repos, but since we will need it whenever we import a new upstream version, we must push it somewhere. The usual choice is salsa.debian.org:
% git remote add -f origin salsa.debian.org:debian/foo.git
% git push --follow-tags -u origin master upstream
You are now ready to proceed as above, making commits to both the upstream source and the debian/ directory. both. at. once. we contain multitudes π
π CONVERTING AN EXISTING PACKAGE π
This section explains how to convert an existing Debian package to this workflow. It should be skipped when debianising a new package.
π No existing git history
% dgit clone foo
% cd foo
% git remote add -f upstream https://some.upstream/foo.git
πΈ Existing git history using another workflow
First, if you don't already have the git history locally, clone it, and obtain the corresponding orig.tar from the archive:
% git clone salsa.debian.org:debian/foo
% cd foo
% origtargz
Now dump any existing patch queue:
% git rm -rf debian/patches
% git commit -m "drop existing quilt patch queue"
Then make new upstream tags available:
% git remote add -f upstream https://some.upstream/foo.git
Now you simply need to ensure that your git HEAD is dgit-compatible, i.e., it is exactly what you would get if you ran
dpkg-buildpackage -i'(?:^|/)\.git(?:/|$)' -I.git -S
and then unpacked the resultant source package. exact same energy, no improvising β
To achieve this, you might need to delete debian/source/local-options. One way to have dgit check your progress is to run dgit build-source.
The first dgit push will require --trust-changelog. If this is the first ever dgit push of the package, consider passing --deliberately-not-fast-forward instead of --trust-changelog. This avoids introducing a new origin commit into your git history. (This origin commit would represent the most recent non-dgit upload of the package, but this should already be represented in your git history.)
β SOURCE PACKAGE AND GIT CONFIGURATION β
π dgit configuration
We must tell dgit not to try to maintain a linear queue of patches to the upstream source:
git config dgit.default.quilt-mode single
This command should be executed in each git clone of this package, including your co-maintainer's. Don't set it more globally, because it is not a good default for working on Debian source packages in general. do NOT make this a global default, bestie, i am begging π
π§ debian/source/options
We set a source package option to help dpkg handle changes to the upstream source:
auto-commit
You don't need to create this file if you are using the version 1.0 source package format.
π₯ BUILDING AND UPLOADING π₯
You can use dpkg-buildpackage(1) for test builds. When you are ready to build just prior to an upload, use dgit sbuild, dgit pbuilder or dgit cowbuilder, as detailed in dgit(1). Routine source-only uploads can be made by just typing
% git debpush
The first time pass --quilt=single. This is especially important if you have converted the package from another workflow. See git-debpush(1).
If you need to upload to NEW, you will need to use dgit push-built. Remember to pass --new if the package is new in the target suite, and to git push to salsa.debian.org afterwards.
As another alternative to dgit build and friends, you can use a tool like gitpkg(1). This works because like dgit, gitpkg(1) enforces that HEAD has exactly the contents of the source package. gitpkg(1) is highly configurable, and one dgit user reports using it to produce and test multiple source packages, from different branches corresponding to each of the current Debian suites. π multi-suite main character energy fr fr
β¨ NEW UPSTREAM RELEASES β¨
Okay bestie, this is the part where your package grows up and gets a whole new upstream version. Buckle in π
πΈ Obtaining the release
β¨ When upstream tags releases in git
Just grab the tags, babes:
% git fetch --tags upstream
If you wanna package an untagged upstream commit β like, because upstream simply does not tag their releases, or because you're out here packaging an upstream development snapshot like a chaotic icon β go read "Using untagged upstream commits" above. It's all there π«Ά
π When upstream releases only tarballs
Okay so you will need the debian/gbp.conf from "When upstream releases only tarballs", up above. You'll also need your upstream branch β remember, earlier we pushed that to salsa.debian.org. So you're gonna need to clone or fetch from there, because you cannot just rely on dgit clone/dgit fetch alone, no cap.
Then, either:
% gbp import-orig ../foo_1.2.3.orig.tar.xz
or, if you have a working watch file, this slay version:
% gbp import-orig --uscan
In the following, replace 1.2.3 with upstream/1.2.3. β¨
π Reviewing & merging the release
Previewing the merge before you commit to it? Iconic behaviour, do that.
First, just check for any new or deleted files that might need to be accounted for in your copyright file:
% git diff --name-status --diff-filter=ADR master..1.2.3 -- . ':!debian'
Then you can review the whole full merge diff like the main character you are:
% git merge-tree `git merge-base master 1.2.3` master 1.2.3 | $PAGER
Once you're satisfied with what's gonna get merged, update your package:
% git merge 1.2.3
% dch -v1.2.3-1 New upstream release.
% git add debian/changelog && git commit -m changelog
If you got a tarball from upstream, you're ready to try a build. But if you merged a git tag from upstream, you'll first need to generate a tarball:
% git deborig
π HANDLING DFSG-NON-FREE MATERIAL π
Yep, sometimes upstream ships stuff that is not free. We love them anyway, but it cannot go in the package. π
πΈ When upstream tags releases in git
We create a DFSG-clean tag, and that's the one we merge to master:
% git checkout -b pre-dfsg 1.2.3
% git rm evil.bin
% git commit -m "upstream version 1.2.3 DFSG-cleaned"
% git tag -s 1.2.3+dfsg
% git checkout master
% git branch -D pre-dfsg
Before you merge that new 1.2.3+dfsg tag to master, you should first figure out whether it would be legally dangerous for the non-free material to be publicly accessible in the git history on dgit-repos. This is the real deal, not a vibe check.
If it would be dangerous, there is a big problem; in this case please consult your archive administrators (for Debian this is the dgit administratordgit-owner@debian.organd the ftpmastersftpmaster@ftp-master.debian.org).
Like, actually message them. Don't just hope for the best π
π When upstream releases only tarballs
The easiest way to handle this is to add a Files-Excluded field to debian/copyright, plus a uversionmangle setting in debian/watch. See uscan(1). Or alternatively, peep the --filter option detailed in gbp-import-orig(1). Both are valid, pick your fighter π
π¦ FORWARDING PATCHES UPSTREAM π¦
The basic steps are, and yes they're numbered for a reason:
- Create a new branch based off upstream's
masterbranch. git-cherry-pick(1)commits from yourmasterbranch onto your new branch.- Push the branch somewhere and ask upstream to merge it, or use
git-format-patch(1)orgit-request-pull(1).
For example (and it is only an example, bestie):
% # fork foo.git on GitHub
% git remote add -f fork git@github.com:spwhitton/foo.git
% git checkout -b fix-error upstream/master
% git config branch.fix-error.pushRemote fork
% git cherry-pick master^2
% git push
% # submit pull request on GitHub
Note that when you merge an upstream release containing your forwarded patches, git and dgit will transparently handle "dropping" the patches that have been forwarded, "retaining" the ones that haven't. So the ones that ate? They leave. The ones that didn't? They stay. Periodt. β¨
β INCORPORATING NMUS β
% dgit pull
Alternatively, you can apply the NMU diff to your repository. But heads up: the next push will then require --trust-changelog. π«Ά
π SEE ALSO π
π AUTHOR π
The original developer and author of this manpage is Sean Whitton <spwhitton@spwhitton.name>. It contains contributions from other dgit contributors too β see the dgit copyright file. Shoutout to everyone who ever touched a line of this π
And that's the whole thing, bestie, we made it to the end π this was dgit-maint-merge(7) from the Debian Project, brought to you by the dgit+tag2upload team β go forth and merge responsibly π
β¨π¦
π¦ where this page comes from
- ubuntu stonking: dgit 17.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms