3 dgit - tutorial for package maintainers, using a workflow centered around git-merge(1)
7 This document describes elements of a workflow for maintaining a
8 non-native Debian package using B<dgit>. The workflow makes the
9 following opinionated assumptions:
15 Git histories should be the non-linear histories produced by
16 git-merge(1), preserving all information about divergent development
17 that was later brought together.
19 If you prefer linear histories, see dgit-maint-rebase(7).
23 Maintaining convenient and powerful git workflows takes priority over
24 the usefulness of the raw Debian source package. The Debian archive
25 is thought of as an output format.
27 For example, we don't spend time curating a series of quilt patches.
28 However, the information such a series would contain is readily
29 available from B<dgit-repos>.
33 It is more important to have the Debian package's git history be a
34 descendent of upstream's git history than to use exactly the orig.tar
35 that upstream makes available for download.
39 =head1 GIT CONFIGURATION
41 Add the following to your ~/.gitconfig to teach git-archive(1) how to
42 compress orig tarballs:
53 =head1 INITIAL DEBIANISATION
55 =head2 When upstream tags releases in git
57 Suppose that the latest stable upstream release is 1.2.2, and this has
58 been tagged '1.2.2' by upstream.
62 % git clone -oupstream https://some.upstream/foo.git
64 % git verify-tag 1.2.2
65 % git reset --hard 1.2.2
66 % git branch --unset-upstream
70 The final command detachs your master branch from the upstream remote,
71 so that git doesn't try to push anything there, or merge unreleased
72 upstream commits. If you want to maintain a copy of your packaging
73 branch on B<alioth.debian.org> in addition to B<dgit-repos>, you can
74 do something like this:
78 % git remote add -f origin git.debian.org:/git/collab-maint/foo.git
79 % git push --follow-tags -u origin master
83 Now go ahead and Debianise your package. Just make commits on the
84 master branch, adding things in the I<debian/> directory. If you need
85 to patch the upstream source, just make commits that change files
86 outside of the I<debian/> directory. It is best to separate commits
87 that touch I<debian/> from commits that touch upstream source, so that
88 the latter can be cherry-picked by upstream.
90 Note that there is no need to maintain a separate 'upstream' branch,
91 unless you also happen to be involved in upstream development. We
92 work with upstream tags rather than any branches, except when
93 forwarding patches (see FORWARDING PATCHES UPSTREAM, below).
95 Finally, you need an orig tarball. Generate one with git-archive(1):
99 % git archive -o ../foo_1.2.2.orig.tar.xz 1.2.2
103 If you are using the version 1.0 source package format, replace 'xz'
106 This tarball is ephemeral and easily regenerated, so we don't commit
107 it anywhere (e.g. with tools like pristine-tar(1)).
109 =head2 When upstream releases only tarballs
111 We need a virtual upstream branch with virtual release tags.
112 gbp-import-orig(1) can manage this for us. To begin
122 Now create I<debian/gbp.conf>:
127 upstream-branch = upsteram
128 debian-branch = master
129 upstream-tag = %(version)s
133 pristine-tar-commit = False
137 Then we can import the upstream version:
141 % git add debian/gbp.conf && git commit -m "create gbp.conf"
142 % gbp import-orig ../foo_1.2.2.orig.tar.xz
146 You are now ready to proceed as above, making commits to both the
147 upstream source and the I<debian/> directory.
149 If you want to maintain a copy of your repository on
150 B<alioth.debian.org>, you should push both the origin and the upstream
155 % git remote add -f origin git.debian.org:/git/collab-maint/foo.git
156 % git push --follow-tags -u origin master upstream
160 =head1 SOURCE PACKAGE CONFIGURATION
162 =head2 debian/source/options
164 We set some source package options such that dgit can transparently
165 handle the "dropping" and "refreshing" of changes to the upstream
175 You don't need to create this file if you are using the version 1.0
176 source package format.
178 =head2 Sample text for README.source
180 It is a good idea to explain how a user can obtain a break down of the
181 changes to the upstream source:
185 The Debian packaging of foo is maintained using dgit. For the sake of
186 an efficient workflow, Debian modifications to the upstream source are
187 squashed into a single patch, rather than a series of quilt patches.
188 To obtain a patch queue for package version 1.2.3-1:
192 # apt-get install dgit
195 % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'
199 See dgit(1), dgit(7) and dgit-maint-merge(7) for more information.
203 =head1 BUILDING AND UPLOADING
205 Use B<dgit build>, B<dgit sbuild>, B<dgit build-source>, and B<dgit
206 push> as detailed in dgit(1). If any command fails, dgit will provide
207 a carefully-worded error message explaining what you should do. If
208 it's not clear, file a bug against dgit. Remember to pass I<--new>
209 for the first upload.
211 As an alternative to B<dgit build> and friends, you can use a tool
212 like gitpkg(1). This works because like dgit, gitpkg(1) enforces that
213 HEAD has exactly the contents of the source package. gitpkg(1) is
214 highly configurable, and one dgit user reports using it to produce and
215 test multiple source packages, from different branches corresponding
216 to each of the current Debian suites.
218 If you want to skip dgit's checks while iterating on a problem with
219 the package build (for example, you don't want to commit your changes
220 to git), you can just run dpkg-buildpackage(1) or debuild(1) instead.
222 =head1 NEW UPSTREAM RELEASES
224 =head2 When upstream tags releases in git
226 It's a good idea to preview the merge of the new upstream release.
227 First, just check for any new or deleted files that may need
228 accounting for in your copyright file:
233 % git diff --stat master..1.2.3 -- . ':!debian'
237 You can then review the full merge diff:
241 % git merge-tree `git merge-base master 1.2.3` master 1.2.3 | $PAGER
245 Once you're satisfied with what will be merged, update your package:
249 % git archive ../foo_1.2.3.orig.tar.xz 1.2.3
251 % dch -v1.2.3-1 New upstream release.
252 % git add debian/changelog && git commit -m changelog
256 and you are ready to try a build.
258 Again, if you are using the version 1.0 source package format, replace
261 =head2 When upstream releases only tarballs
267 % gbp import-orig ../foo_1.2.2.orig.tar.xz
271 or if you have a working watch file
275 % gbp import-orig --uscan
279 =head1 HANDLING DFSG-NON-FREE MATERIAL
281 =head2 When upstream tags releases in git
283 We create a DFSG-clean tag to merge to master:
287 % git checkout -b pre-dfsg 1.2.3
289 % git commit -m "upstream version 1.2.3 DFSG-cleaned"
290 % git tag -s 1.2.3+dfsg
291 % git checkout master
292 % git branch -D pre-dfsg
296 Before merging the new 1.2.3+dfsg tag to master, you should first
297 determine whether it would be legally dangerous for the non-free
298 material to be publicly accessible in the git history on
299 B<dgit-repos>. If it would be, pass B<--squash> to git-merge(1).
301 =head2 When upstream releases only tarballs
303 The easiest way to handle this is to add a B<Files-Excluded> field to
304 I<debian/copyright>, and a B<uversionmangle> setting in
305 I<debian/watch>. See uscan(1). Alternatively, see the I<--filter>
306 option detailed in gbp-import-orig(1).
308 =head1 FORWARDING PATCHES UPSTREAM
316 Create a new branch based off upstream's master branch.
320 git-cherry-pick(1) commits from your master branch onto your new
325 Push the branch somewhere and ask upstream to merge it, or use
326 git-format-patch(1) or git-request-pull(1).
330 For example (and it is only an example):
334 % # fork foo.git on GitHub
335 % git remote add -f fork git@github.com:spwhitton/foo.git
336 % git checkout -b fix-error upstream/master
337 % git config branch.fix-error.pushRemote fork
338 % git cherry-pick master^2
340 % # submit pull request on GitHub
344 Note that when you merge an upstream release containing your forwarded
345 patches, git and dgit will transparently handle "dropping" the patches
346 that have been forwarded, "retaining" the ones that haven't.
348 =head1 INCORPORATING NMUS
356 Alternatively, you can apply the NMU diff to your repository. The
357 next push will then require I<--overwrite>.
365 This tutorial was written and is maintained by Sean Whitton <spwhitton@spwhitton.name>. It contains contributions from other dgit contributors too - see the dgit copyright file.