Importing Sources Importing already existing &debian; packages Importing an already exsting debian package into a git repository is as easy as: &git-import-dsc; package_0.1-1.dsc This will create a new git repository named after the imported package, put the upstream sources onto the and the debian patch on the . In case of a debian native package only the is being used. You can specify alternative branch names via the and options or via the and options in the configuration file. If you want to be able to exactly recreate the original tarball (orig.tar.gz) from &git; you should also specify the option. This is recommended. If you want to import further versions you can change into your shiny new &git; repository and just continue with the same command: cd package/ &git-import-dsc; package_0.1-2.dsc &git-import-dsc; package_0.1-3.dsc &git-import-dsc; package_0.2-1.dsc Or you can import all versions at once using &git-import-dscs;: &git-import-dscs; /path/to/history/package_*.dsc This will create a &git; repository if necessary and import all versions sorted by version number. Importing a new upstream version Change into your git repository (which can be empty), make sure it has all local modifications committed and run either of: &git-import-orig; /path/to/package_0.2.orig.tar.gz &git-import-orig; /path/to/package_0.2.tar.bz2 &git-import-orig; /path/to/package-0.2/ This puts the upstream souces onto the and tags them accordingly (the default tag format is upstream/%(version)s). The result is then merged onto the and a new &debian; changelog entry is created. You can again specify different branch names via the and options. You can also filter out content you don't want imported: &git-import-orig; ='CVS/*' /path/to/package_0.2.orig.tar.gz The option can be used multiple times for more complex filtering. If you expect a merge conflict you can delay the merge to the via the and pull in the changes from the later. If you want to be able to exactly recreate the original tarball (orig.tar.gz) from &git; you should also specify the option. This is recommended. To customize the commit message used by &git-import-orig; use the option. This string is a standard python format string, into which the version variable is interpolated. (i.e., use %(version)s in your message to get the imported upstream version). Converting an existing &git; repository If the &git; repository wasn't created with &git-import-dsc; you have to tell &git-buildpackage; and friends where to find the upstream sources. Upstream sources on a branch If the upstream sources are already on a separate branch things are pretty simple. You can either rename that branch to the default name upstream with: &gitcmd; branch upstream theupstream-branch &gitcmd; branch theupstream-branch or you can tell &git-buildpackage; the name of the branch to use as : cat <<EOF > .git/gbp.conf [DEFAULT] # this is the upstream-branch: upstream-branch=theupstream-branch EOF If you then use &git-import-orig; to import new upstream sources, they will from now on end up on theupstream-branch and merged to the . Upstream sources not on a branch If you don't have an upstream branch but started your repository with only the upstream sources (not the debian patch) you can simply branch from that point. So use &gitkcmd; or &gitcmd;-log to locate the commit-id of that commit and create the upstream branch from there, e.g.: COMMIT_ID=`&gitcmd; log --pretty=oneline | tail -1 | awk '{ print $1 }'` &gitcmd; branch upstream $COMMIT_ID The important thing here is that the COMMIT_ID specifies a point on the master branch that carried only the upstream sources and not the debian modifications. The above example assumes that this was the first commit to that repository. There's currently no easy way to create the if you never had the upstream sources as a single commit. Using &git-import-orig; on such repositories might lead to unexpected merge results. In order to fix this you can prepend the upstream sources as a single commit to your tree using &git;'s grafts. Afterwards you can simply create a branch as explained above and &git-import-orig; will work as expected. Alternatively, if you are only importing source from original tarballs (for instance when converting from a Subversion repository where the mergeWithUpstream was set for svn-buildpackage), you can create an empty upstream branch with the following commands: git checkout upstream git rm . git commit 'Initial upstream branch.' git checkout master With Git versions lower than 1.7.2.3, the commands are slightly more complicated: git symbolic-ref HEAD refs/heads/upstream git rm . git commit 'Initial upstream branch.' git checkout master Starting a Debian package from scratch So far we assumed you already have a &debian; package to start with but what if you want to start a new package? First create an empty repository: mkdir package-0.1 cd package-0.1 git init Then you import the upstream sources, branch off the branch and add the debian files (e.g. via dh_make): &git-import-orig; 0.1 ../package-0.1.tar.gz dh_make That's it, you're done. If you want to publish you're new repository you can use &gbp-create-remote-repo;. When upstream uses GIT If upstream already uses git for packaging there are several ways to handle packaging. Two will be described in a bit detail here: No upstream tarballs If upstream doesn't build upstream tarballs or you don't care about them the simplest way is to clone upstreams repository and create a separate packaging branch in there. &git-buildpackage; will by default create an upstream tarball for you. By default it will be created from the tag name given by the option. You can customize it's value via the configuration variable. A common upstream format is to put a v in front of the version number. In this case the configuration option would look like: [git-buildpackage] upstream-tag = v%(version)s version will be replaced with the upstream version number as read from debian/changelog. If you're using &pristine-tar; you can make &git-buildpackage commit the tarball back to the pristine-tar branch by using the option. Upstream tarballs If you want to track upstream's git but continue to import the upstream tarballs, e.g. to make sure the tarball uploaded to &debian; has the same checksum as upstream's you can use the option when importing new tarballs with &git-import-orig;. Assuming you have the upstream source in your repository with a tag v0.0.1 you can use: &git-import-orig; --upstream-vcs-tag=v0.0.1 foo_0.0.1.orig.tar.gz to add upstream's tag as additional parent to the merge commit. See #664771 for more details.