CINXE.COM

Code/Git - Launchpad Help

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta name="robots" content="index,nofollow"> <title>Code/Git - Launchpad Help</title> <script type="text/javascript" src="/moin_static198/common/js/common.js"></script> <script type="text/javascript"> <!-- var search_hint = "Search"; //--> </script> <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/moin_static198/lp20/css/common.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="screen" href="/moin_static198/lp20/css/screen.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="print" href="/moin_static198/lp20/css/print.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="projection" href="/moin_static198/lp20/css/projection.css"> <!-- css only for MS IE6/IE7 browsers --> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/moin_static198/lp20/css/msie.css"> <![endif]--> <link rel="alternate" title="Launchpad Help: Code/Git" href="/Code/Git?diffs=1&amp;show_att=1&amp;action=rss_rc&amp;unique=0&amp;page=Code%2FGit&amp;ddiffs=1" type="application/rss+xml"> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-12833497-4']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <link rel="Start" href="/FrontPage"> <link rel="Alternate" title="Wiki Markup" href="/Code/Git?action=raw"> <link rel="Alternate" media="print" title="Print View" href="/Code/Git?action=print"> <link rel="Up" href="/Code"> <link rel="Search" href="/FindPage"> <link rel="Index" href="/TitleIndex"> <link rel="Glossary" href="/WordIndex"> <link rel="Help" href="/HelpOnFormatting"> </head> <body lang="en" dir="ltr"> <div id="header"> <h1> <a href="https://help.launchpad.net/" class="header-link"> <img src=' /moin_static198/lp20/img/logo.png ' /> launchpad <strong>help</strong></a> </h1> <div id="finder"> <div class="fixbox"> <form id="searchform" method="get" action=""> <input type="hidden" name="action" value="fullsearch"> <input type="hidden" name="context" value="180"> <input id="searchinput" type="text" name="value" value="" size="20" onfocus="searchFocus(this)" onblur="searchBlur(this)" onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search"> </form> </div> <ul class="editbar"><li><span class="disabled">Immutable Page</span></li><li><a class="nbinfo" href="/Code/Git?action=info" rel="nofollow">Info</a></li><li><a class="nbattachments" href="/Code/Git?action=AttachFile" rel="nofollow">Attachments</a></li><li> <form class="actionsmenu" method="GET" action="/Code/Git"> <div> <label>More Actions:</label> <select name="action" onchange="if ((this.selectedIndex != 0) && (this.options[this.selectedIndex].disabled == false)) { this.form.submit(); } this.selectedIndex = 0;"> <option value="raw">Raw Text</option> <option value="print">Print View</option> <option value="RenderAsDocbook">Render as Docbook</option> <option value="refresh">Delete Cache</option> <option value="show" disabled class="disabled">------------------------</option> <option value="SpellCheck">Check Spelling</option> <option value="LikePages">Like Pages</option> <option value="LocalSiteMap">Local Site Map</option> <option value="show" disabled class="disabled">------------------------</option> <option value="RenamePage" disabled class="disabled">Rename Page</option> <option value="DeletePage" disabled class="disabled">Delete Page</option> <option value="show" disabled class="disabled">------------------------</option> <option value="show" disabled class="disabled">Subscribe User</option> <option value="show" disabled class="disabled">------------------------</option> <option value="show" disabled class="disabled">Remove Spam</option> <option value="show" disabled class="disabled">Revert to this revision</option> <option value="PackagePages">Package Pages</option> <option value="SyncPages">Sync Pages</option> <option value="show" disabled class="disabled">------------------------</option> <option value="Load">Load</option> <option value="Save">Save</option> <option value="SlideShow">SlideShow</option> </select> <input type="submit" value="Do"> </div> <script type="text/javascript"> <!--// Init menu actionsMenuInit('More Actions:'); //--> </script> </form> </li></ul> </div> </div> <div id="locationline"> </div> <div id="sepbar">&nbsp;</div> <div id="login"> <div class="fl"> <h1 class="maintitle"> Code/Git </h1> </div> <div class="fr"> Not logged in - <a href="/?action=login">Log In / Register</a> </div> </div> <div id="pageline"><hr style="display:none;"></div> <div class="message"> </div> <div id="page" lang="en" dir="ltr"> <div dir="ltr" id="content" lang="en"><span class="anchor" id="top"></span> <span class="anchor" id="line-1"></span><p class="line867"><small><a href="/FrontPage">Launchpad Help</a> &gt; <a href="/Code">Code</a> &gt; Git </small> <span class="anchor" id="line-2"></span><span class="anchor" id="line-3"></span><div><table style="&amp;quot; float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em; &amp;quot;"><tbody><tr> <td style="&amp;quot; padding:0.5em; &amp;quot;"><p class="line891"><div class="table-of-contents"><p class="table-of-contents-heading">Contents<ol><li> <a href="#Overview">Overview</a></li><li> <a href="#What.27s_supported.3F">What's supported?</a></li><li> <a href="#What_will_be_supported.3F">What will be supported?</a></li><li> <a href="#Configuring_Git">Configuring Git</a></li><li> <a href="#Getting_code">Getting code</a></li><li> <a href="#Pushing_code">Pushing code</a><ol><li> <a href="#Permissions">Permissions</a></li></ol></li><li> <a href="#Repository_URLs">Repository URLs</a></li><li> <a href="#HTTPS_authentication">HTTPS authentication</a><ol><li> <a href="#Access_Tokens">Access Tokens</a></li><li> <a href="#Valid_scopes">Valid scopes</a></li><li> <a href="#Generating_access_tokens">Generating access tokens</a><ol><li> <a href="#Via_UI">Via UI</a></li><li> <a href="#Via_API">Via API</a></li></ol></li><li> <a href="#Using_access_tokens">Using access tokens</a></li><li> <a href="#Revoking_access_tokens">Revoking access tokens</a></li></ol></li><li> <a href="#Linking_to_bugs">Linking to bugs</a></li><li> <a href="#Mirroring_repositories_from_other_sites">Mirroring repositories from other sites</a></li><li> <a href="#Converting_from_Bazaar_to_Git">Converting from Bazaar to Git</a></li><li> <a href="#Deleting_a_Git_repository">Deleting a Git repository</a></li></ol></div></td> </tr> </tbody></table></div><span class="anchor" id="line-4"></span><span class="anchor" id="line-5"></span><p class="line867"> <h1 id="Overview">Overview</h1> <span class="anchor" id="line-6"></span><span class="anchor" id="line-7"></span><p class="line862">Launchpad supports hosting <a class="http" href="http://git-scm.com/">Git</a> repositories. This is distinct from the <a href="/Code/Imports">code import</a> facility that Launchpad has included for many years; it is now possible to host Git repositories on Launchpad directly. <span class="anchor" id="line-8"></span><span class="anchor" id="line-9"></span><p class="line874">Git repositories use a somewhat different model from Bazaar branches: operations such as cloning happen at the level of a repository, but it is common for a single repository to contain many branches. This means that the Launchpad interface needs to be laid out somewhat differently to support that. <span class="anchor" id="line-10"></span><span class="anchor" id="line-11"></span><p class="line867"> <h1 id="What.27s_supported.3F">What's supported?</h1> <span class="anchor" id="line-12"></span><span class="anchor" id="line-13"></span><p class="line874">This summary is up-to-date as of December 2022. <span class="anchor" id="line-14"></span><span class="anchor" id="line-15"></span><p class="line874">Launchpad supports Git hosting. This means that you can: <span class="anchor" id="line-16"></span><span class="anchor" id="line-17"></span><ul><li>push Git repositories over SSH or HTTPS <span class="anchor" id="line-18"></span></li><li>clone repositories over git://, SSH, or HTTPS <span class="anchor" id="line-19"></span></li><li>see summary information on repositories and the branches they contain in the Launchpad web UI <span class="anchor" id="line-20"></span></li><li>follow links from the Launchpad web UI to a full-featured code browser <span class="anchor" id="line-21"></span></li><li>push and clone private repositories, if you have a commercial subscription to Launchpad <span class="anchor" id="line-22"></span></li><li>propose merges from one branch to another, including in a different repository, provided that they are against the same project or package <span class="anchor" id="line-23"></span></li><li>link Launchpad bugs to merge proposals <span class="anchor" id="line-24"></span></li><li><p class="line862">add <a href="/API/Webhooks">webhooks</a> to notify third-party services when repositories are changed <span class="anchor" id="line-25"></span></li><li><p class="line862">use <a href="/Packaging/SourceBuilds">recipes</a> to build packages in PPAs for code in Launchpad-hosted Git repositories <span class="anchor" id="line-26"></span></li><li>mirror repositories from other sites <span class="anchor" id="line-27"></span><span class="anchor" id="line-28"></span></li></ul><p class="line867"> <h1 id="What_will_be_supported.3F">What will be supported?</h1> <span class="anchor" id="line-29"></span><span class="anchor" id="line-30"></span><p class="line874">Launchpad's Bazaar support has grown many features over the years, and it will take some time to bring our Git support up to full parity with it. Here's an incomplete list of some of the features we expect to add: <span class="anchor" id="line-31"></span><span class="anchor" id="line-32"></span><ul><li>useful subscriptions (currently only attribute change notifications work, which are not usually very interesting in themselves) <span class="anchor" id="line-33"></span></li><li>RSS feeds <span class="anchor" id="line-34"></span></li><li>an integrated code browser <span class="anchor" id="line-35"></span><span class="anchor" id="line-36"></span></li></ul><p class="line874">Here's a short list of known bugs that you don't need to tell us about: <span class="anchor" id="line-37"></span><span class="anchor" id="line-38"></span><ul><li>the interface for registering merge proposals is very rough <span class="anchor" id="line-39"></span><span class="anchor" id="line-40"></span></li></ul><p class="line867"> <h1 id="Configuring_Git">Configuring Git</h1> <span class="anchor" id="line-41"></span><span class="anchor" id="line-42"></span><p class="line862">Git identifies repositories using URLs. Unlike Bazaar, there is no built-in abbreviation for repositories hosted on Launchpad, but it is very easy to add such a thing yourself. Edit <tt class="backtick">~/.gitconfig</tt> and add these lines, where <tt class="backtick">USER</tt> is your Launchpad username: <span class="anchor" id="line-43"></span><span class="anchor" id="line-44"></span><span class="anchor" id="line-45"></span><pre><span class="anchor" id="line-1"></span>[url &quot;git+ssh://USER@git.launchpad.net/&quot;] <span class="anchor" id="line-2"></span> insteadof = lp:</pre><span class="anchor" id="line-46"></span><p class="line862">This allows you to type <tt class="backtick">git&nbsp;clone&nbsp;lp:REPOSITORY</tt> instead of <tt class="backtick">git&nbsp;clone&nbsp;git+ssh://git.launchpad.net/REPOSITORY</tt>. <span class="anchor" id="line-47"></span><span class="anchor" id="line-48"></span><p class="line874">The rest of this documentation assumes that you have configured Git this way. <span class="anchor" id="line-49"></span><span class="anchor" id="line-50"></span><p class="line862">You should check the <a href="/SSHFingerprints">fingerprint</a> of git.launchpad.net when prompted to do so by SSH. <span class="anchor" id="line-51"></span><span class="anchor" id="line-52"></span><p class="line867"> <h1 id="Getting_code">Getting code</h1> <span class="anchor" id="line-53"></span><span class="anchor" id="line-54"></span><p class="line862">You can fetch the default repository for a project like this: <span class="anchor" id="line-55"></span><span class="anchor" id="line-56"></span><pre><span class="anchor" id="line-1-1"></span>$ git clone lp:PROJECT</pre><span class="anchor" id="line-57"></span><span class="anchor" id="line-58"></span><p class="line862">For example, <tt class="backtick">git&nbsp;clone&nbsp;lp:launchpad</tt> fetches Launchpad itself (or will once we've finished converting it to Git!). <span class="anchor" id="line-59"></span><span class="anchor" id="line-60"></span><p class="line862">To keep your local clone up to date, run: <span class="anchor" id="line-61"></span><span class="anchor" id="line-62"></span><pre><span class="anchor" id="line-1-2"></span>$ git pull</pre><span class="anchor" id="line-63"></span><span class="anchor" id="line-64"></span><p class="line867"> <h1 id="Pushing_code">Pushing code</h1> <span class="anchor" id="line-65"></span><span class="anchor" id="line-66"></span><p class="line862">You can add a &quot;remote&quot; to your repository like this, if you own the project: <span class="anchor" id="line-67"></span><span class="anchor" id="line-68"></span><pre><span class="anchor" id="line-1-3"></span>$ git remote add origin lp:PROJECT</pre><span class="anchor" id="line-69"></span><span class="anchor" id="line-70"></span><p class="line862">Or like this (where <tt class="backtick">USER</tt> is your Launchpad username), if you do not own the project but want to contribute to it: <span class="anchor" id="line-71"></span><span class="anchor" id="line-72"></span><pre><span class="anchor" id="line-1-4"></span>$ git remote add origin lp:~USER/PROJECT</pre><span class="anchor" id="line-73"></span><span class="anchor" id="line-74"></span><p class="line862">Or to push a repository that isn't part of any Launchpad project or package, e.g. an ad-hoc experiment: <span class="anchor" id="line-75"></span><span class="anchor" id="line-76"></span><pre><span class="anchor" id="line-1-5"></span>$ git remote add origin lp:~USER/+git/REPOSITORY-NAME</pre><span class="anchor" id="line-77"></span><span class="anchor" id="line-78"></span><p class="line862">Now, you can push a branch using a command such as this: <span class="anchor" id="line-79"></span><span class="anchor" id="line-80"></span><pre><span class="anchor" id="line-1-6"></span>$ git push origin my-changes</pre><span class="anchor" id="line-81"></span><span class="anchor" id="line-82"></span><p class="line867"> <h2 id="Permissions">Permissions</h2> <span class="anchor" id="line-83"></span><span class="anchor" id="line-84"></span><p class="line874">By default, repository owners may create, push, force-push, or delete any branch or tag in their repositories, and nobody else may modify them in any way. <span class="anchor" id="line-85"></span><span class="anchor" id="line-86"></span><p class="line874">Repository owners can use the &quot;Manage permissions&quot; page of a repository to change this by protecting branches or tags. By default, protecting a branch implicitly prevents repository owners from force-pushing to it or deleting it, while protecting a tag prevents repository owners from moving it. You can modify these default permission grants to be more restrictive (for example, you might prevent anyone from pushing to an archived branch), or to grant other permissions (for example, you might want to allow a contributor to push to certain branches in your repository without owning it). <span class="anchor" id="line-87"></span><span class="anchor" id="line-88"></span><p class="line862">You may create rules that match a single branch or tag, or wildcard rules that match a pattern: for example, <tt class="backtick">*</tt> matches everything, while <tt class="backtick">stable/*</tt> matches <tt class="backtick">stable/1.0</tt> but not <tt class="backtick">master</tt>. The pattern is implemented using Python's <a class="https" href="https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch">fnmatch</a>. <span class="anchor" id="line-89"></span><span class="anchor" id="line-90"></span><p class="line874">Any owner of a repository can change its permissions, so restricting permissions for other repository owners is not a strict security barrier. However, you can use the &quot;View activity&quot; page of a repository to see what permission changes have been made. <span class="anchor" id="line-91"></span><span class="anchor" id="line-92"></span><p class="line874">Launchpad works out the effective permissions that a user has on a protected branch or tag as follows: <span class="anchor" id="line-93"></span><span class="anchor" id="line-94"></span><ol type="1"><li>Take all the rules that match the branch or tag. <span class="anchor" id="line-95"></span></li><li>For each matching rule, select any grants whose grantee matches the user, as long as the same grantee has not already been seen in an earlier matching rule. (A user can be matched by more than one grantee: for example, they might be in multiple teams.) <span class="anchor" id="line-96"></span></li><li>If the user is an owner of the repository and there was no previous &quot;Repository owner&quot; grant, then add an implicit grant allowing them to create or push. <span class="anchor" id="line-97"></span></li><li>The effective permission set is the union of the permissions granted by all the selected grants. <span class="anchor" id="line-98"></span><span class="anchor" id="line-99"></span></li></ol><p class="line867"> <h1 id="Repository_URLs">Repository URLs</h1> <span class="anchor" id="line-100"></span><span class="anchor" id="line-101"></span><p class="line874">Every Git repository hosted on Launchpad has a full &quot;canonical&quot; URL of one of these forms (these are the versions you'd use in a web browser; you only need to change the scheme and host parts for the command-line Git client): <span class="anchor" id="line-102"></span><span class="anchor" id="line-103"></span><dl><dt>https://code.launchpad.net/~OWNER/PROJECT/+git/REPOSITORY</dt><dd>This identifies a repository for an upstream project. <span class="anchor" id="line-104"></span></dd><dt>https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE/+git/REPOSITORY</dt><dd>This identifies a repository for a source package in a distribution. <span class="anchor" id="line-105"></span></dd><dt>https://code.launchpad.net/~OWNER/+git/REPOSITORY</dt><dd>This identifies a &quot;personal&quot; repository with no particular connection to any project or package (like &quot;+junk&quot; in Launchpad's Bazaar code hosting). <span class="anchor" id="line-106"></span><span class="anchor" id="line-107"></span></dd></dl><p class="line874">These are unique, but can involve quite a lot of typing, and in most cases there's no need for more than one repository per owner and target (project or package). Launchpad therefore has the notion of &quot;default repositories&quot;. A repository can be the default for a target, in which case it has one of these forms: <span class="anchor" id="line-108"></span><span class="anchor" id="line-109"></span><dl><dt>https://code.launchpad.net/PROJECT</dt><dd>This is the default repository for an upstream project. <span class="anchor" id="line-110"></span></dd><dt>https://code.launchpad.net/DISTRIBUTION/+source/SOURCE</dt><dd>This is the default repository for a source package in a distribution. <span class="anchor" id="line-111"></span><span class="anchor" id="line-112"></span></dd></dl><p class="line874">Or a repository can be a person's or a team's default for a target, in which case it has one of these forms: <span class="anchor" id="line-113"></span><span class="anchor" id="line-114"></span><dl><dt>https://code.launchpad.net/~OWNER/PROJECT</dt><dd>This is an owner's default repository for an upstream project. <span class="anchor" id="line-115"></span></dd><dt>https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE</dt><dd>This is an owner's default repository for a source package in a distribution. <span class="anchor" id="line-116"></span><span class="anchor" id="line-117"></span></dd></dl><p class="line874">We expect that projects hosting their code on Launchpad will normally have their primary repository set as the default for the project, and contributors will normally push to branches in owner-default repositories. The extra flexibility with named repositories allows for situations such as separate private repositories containing embargoed security fixes. <span class="anchor" id="line-118"></span><span class="anchor" id="line-119"></span><p class="line867"> <h1 id="HTTPS_authentication">HTTPS authentication</h1> <span class="anchor" id="line-120"></span><span class="anchor" id="line-121"></span><p class="line867"> <h2 id="Access_Tokens">Access Tokens</h2> <span class="anchor" id="line-122"></span><span class="anchor" id="line-123"></span><p class="line874">To push repositories over HTTPS, or to clone or pull private repositories over HTTPS, you need to use access tokens. These are text strings generated by Launchpad that can be used as HTTP passwords for particular repositories, with scope limitations and optional expiry dates. <span class="anchor" id="line-124"></span><span class="anchor" id="line-125"></span><p class="line874">You can generate access tokens for a particular repository - which will grant access to that particular repository, or for a project - which will grant access to all repositories within that project (accessible by the user that generated them). <span class="anchor" id="line-126"></span><span class="anchor" id="line-127"></span><p class="line867"> <h2 id="Valid_scopes">Valid scopes</h2> <span class="anchor" id="line-128"></span><p class="line862">For use with the <tt class="backtick">git</tt> client, the relevant scopes are <tt class="backtick">repository:pull</tt> to allow cloning or pulling the repository, and <tt class="backtick">repository:push</tt> to allow pushing the repository; you may select either or both. <span class="anchor" id="line-129"></span><span class="anchor" id="line-130"></span><p class="line862">There is also <tt class="backtick">repository:build_status</tt> which allows seeing and updating the build status for all commits in a repository. <span class="anchor" id="line-131"></span><span class="anchor" id="line-132"></span><p class="line867"> <h2 id="Generating_access_tokens">Generating access tokens</h2> <span class="anchor" id="line-133"></span><span class="anchor" id="line-134"></span><p class="line867"> <h3 id="Via_UI">Via UI</h3> <span class="anchor" id="line-135"></span><p class="line874">To generate an access token for a repository or project: <span class="anchor" id="line-136"></span><ol type="1"><li>Navigate to it in the Launchpad web UI <span class="anchor" id="line-137"></span></li><li>Select &quot;Manage access tokens&quot; <span class="anchor" id="line-138"></span></li><li>Enter a description of the token <span class="anchor" id="line-139"></span></li><li>Select some scopes that the token should grant <span class="anchor" id="line-140"></span></li><li>[Optional] You may also set an expiry date for the token if you wish <span class="anchor" id="line-141"></span></li><li>Press &quot;Create token&quot; <span class="anchor" id="line-142"></span><span class="anchor" id="line-143"></span></li></ol><p class="line874">Launchpad will generate a token and show it to you: note that Launchpad only stores a hash of the token for verification and not the token itself, so you must make a copy of the token at this point as Launchpad will not be able to show it to you again. <span class="anchor" id="line-144"></span><span class="anchor" id="line-145"></span><p class="line867"> <h3 id="Via_API">Via API</h3> <span class="anchor" id="line-146"></span><span class="anchor" id="line-147"></span><p class="line862">Alternatively, you can generate access tokens using the <a href="/API">Launchpad API</a>, as follows: <span class="anchor" id="line-148"></span><span class="anchor" id="line-149"></span><span class="anchor" id="line-150"></span><span class="anchor" id="line-151"></span><span class="anchor" id="line-152"></span><span class="anchor" id="line-153"></span><span class="anchor" id="line-154"></span><span class="anchor" id="line-155"></span><span class="anchor" id="line-156"></span><span class="anchor" id="line-157"></span><span class="anchor" id="line-158"></span><span class="anchor" id="line-159"></span><pre><span class="anchor" id="line-1-7"></span># The path argument should be the clone URL for your repository or project, without the <span class="anchor" id="line-2-1"></span># leading &quot;https://git.launchpad.net/&quot;. For example, if you want to <span class="anchor" id="line-3"></span># generate a token for https://git.launchpad.net/~user/example-project, use <span class="anchor" id="line-4"></span># path=&quot;~user/example-project&quot;. <span class="anchor" id="line-5"></span>&gt;&gt;&gt; repository = lp.git_repositories.getByPath(path=&quot;...&quot;) <span class="anchor" id="line-6"></span># Generate a pull-only token: <span class="anchor" id="line-7"></span>&gt;&gt;&gt; repository.issueAccessToken(description=&quot;pull token&quot;, scopes=[&quot;repository:pull&quot;]) <span class="anchor" id="line-8"></span># Generate a push-only token: <span class="anchor" id="line-9"></span>&gt;&gt;&gt; repository.issueAccessToken(description=&quot;push token&quot;, scopes=[&quot;repository:push&quot;]) <span class="anchor" id="line-10"></span># Generate a token that can either pull or push: <span class="anchor" id="line-11"></span>&gt;&gt;&gt; repository.issueAccessToken(description=&quot;pull/push token&quot;, scopes=[&quot;repository:pull&quot;, &quot;repository:push&quot;])</pre><span class="anchor" id="line-160"></span><span class="anchor" id="line-161"></span><p class="line862">Similarly, to create a project access token: <span class="anchor" id="line-162"></span><span class="anchor" id="line-163"></span><span class="anchor" id="line-164"></span><span class="anchor" id="line-165"></span><pre><span class="anchor" id="line-1-8"></span>&gt;&gt;&gt; project = lp.load(&quot;&lt;name of project&gt;&quot;) <span class="anchor" id="line-2-2"></span># Generate a token that can either pull or push: <span class="anchor" id="line-3-1"></span>&gt;&gt;&gt; project.issueAccessToken(description=&quot;pull/push token&quot;, scopes=[&quot;repository:pull&quot;, &quot;repository:push&quot;])</pre><span class="anchor" id="line-166"></span><span class="anchor" id="line-167"></span><p class="line867"> <h2 id="Using_access_tokens">Using access tokens</h2> <span class="anchor" id="line-168"></span><span class="anchor" id="line-169"></span><p class="line862">You can use access tokens as HTTPS passwords, in conjunction with your Launchpad username. For one-off testing you can just enter these when <tt class="backtick">git</tt> prompts you to do so. However, if you're using them more seriously then you will probably want to store them somewhere; for that, see the advice from &quot;Pro Git&quot; on <a class="https" href="https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage">credential storage</a>. <span class="anchor" id="line-170"></span><span class="anchor" id="line-171"></span><p class="line867"> <h2 id="Revoking_access_tokens">Revoking access tokens</h2> <span class="anchor" id="line-172"></span><span class="anchor" id="line-173"></span><p class="line874">Tokens can be revoked in Launchpad's web UI by anyone that can see them listed, where a user can see a token listed if they are the direct or indirect (through team membership) owners of the token, or if they are the direct or indirect owners of the git repository/project. Owners of the git repository/project can see all its tokens. <span class="anchor" id="line-174"></span><span class="anchor" id="line-175"></span><p class="line867"> <h1 id="Linking_to_bugs">Linking to bugs</h1> <span class="anchor" id="line-176"></span><span class="anchor" id="line-177"></span><p class="line862">Git-based merge proposals can be linked to Launchpad bugs. This can be done manually from the web UI for the merge proposal, but normally you should just mention the Launchpad bug in the commit message of one of the commits you want to merge. The required commit message text to link to bugs #XXX and #YYY looks like this: <span class="anchor" id="line-178"></span><span class="anchor" id="line-179"></span><pre><span class="anchor" id="line-1-9"></span>LP: #XXX, #YYY</pre><span class="anchor" id="line-180"></span><span class="anchor" id="line-181"></span><p class="line862">Technically, the commit message needs to match this regular expression, case-insensitively: <span class="anchor" id="line-182"></span><span class="anchor" id="line-183"></span><pre><span class="anchor" id="line-1-10"></span>/lp:\s+\#\d+(?:,\s*\#\d+)*/</pre><p class="line862"> This is the same pattern used to match Launchpad bug references in <tt class="backtick">debian/changelog</tt> files in source packages.<span class="anchor" id="line-184"></span><span class="anchor" id="line-185"></span><p class="line874">Bugs are not automatically closed when merge proposals land, because the policy for when that should happen varies from project to project: for example, projects often only close bugs when they make releases, or when their code is deployed to production sites. <span class="anchor" id="line-186"></span><span class="anchor" id="line-187"></span><p class="line874">Users familiar with Bazaar on Launchpad should note that the model for Git bug linking is slightly different: bugs are linked to merge proposals rather than to individual branches. This difference is mainly because individual branches within a Git repository are often much more ephemeral than Bazaar branches. <span class="anchor" id="line-188"></span><span class="anchor" id="line-189"></span><p class="line862">If you need a more advanced bug-handling workflow for your project, you can use a <a href="/API/Webhooks">webhook</a> to help. See <a class="https" href="https://git.launchpad.net/kicad-git-hook">kicad-git-hook</a> for an example contributed by a Launchpad user. <span class="anchor" id="line-190"></span><span class="anchor" id="line-191"></span><p class="line867"> <h1 id="Mirroring_repositories_from_other_sites">Mirroring repositories from other sites</h1> <span class="anchor" id="line-192"></span><span class="anchor" id="line-193"></span><p class="line874">You can tell Launchpad to create a repository which is imported from some other site. There are two ways to set this up. <span class="anchor" id="line-194"></span><span class="anchor" id="line-195"></span><ol type="1"><li>This method is preferred in the common case of importing the upstream repository for a project. <span class="anchor" id="line-196"></span><ul><li>Go to the main page in Launchpad for a project you maintain, and follow the &quot;Code&quot; link under &quot;Configuration options&quot;. <span class="anchor" id="line-197"></span></li><li>Set &quot;Version control system&quot; to &quot;Git&quot; if necessary. <span class="anchor" id="line-198"></span></li><li>Select &quot;Import a Git repository hosted somewhere else&quot;. <span class="anchor" id="line-199"></span></li><li>Fill in the repository name (this should normally just be the project name). <span class="anchor" id="line-200"></span></li><li>Set the repository owner if necessary (defaults to you, can be any public team you participate in). <span class="anchor" id="line-201"></span></li><li>Fill in the URL of the remote repository. <span class="anchor" id="line-202"></span></li><li>Launchpad will create the repository, set it as the default for your project, and schedule an import. <span class="anchor" id="line-203"></span></li></ul></li><li>This method is useful for other cases, such as importing repositories that are not the primary upstream repository for a project. <span class="anchor" id="line-204"></span><ul><li><p class="line862">Go to the &quot;<a class="https" href="https://code.launchpad.net/+code-imports/+new">Request a code import</a>&quot; page. <span class="anchor" id="line-205"></span></li><li>Select &quot;Git&quot; for both the version control system and the target version control system. <span class="anchor" id="line-206"></span></li><li>Fill in the other details as above. <span class="anchor" id="line-207"></span></li><li><p class="line862">Launchpad will create the repository and schedule an import, but in this case it will <strong>not</strong> set it as the default for your project. <span class="anchor" id="line-208"></span><span class="anchor" id="line-209"></span></li></ul></li></ol><p class="line874">In either case, Launchpad will mirror the whole repository from the remote site, and will keep its copy up to date regularly. You won't be able to push directly to the imported repository on Launchpad, but you can create another repository in the same project and push branches to that, and even create merge proposals if you want (though you may have to tell the upstream maintainer about them separately!). You can create source package recipes or Snap packages based on branches in the imported repository. <span class="anchor" id="line-210"></span><span class="anchor" id="line-211"></span><p class="line874">Please note that Launchpad can only mirror public repositories. <span class="anchor" id="line-212"></span><span class="anchor" id="line-213"></span><p class="line867"> <h1 id="Converting_from_Bazaar_to_Git">Converting from Bazaar to Git</h1> <span class="anchor" id="line-214"></span><span class="anchor" id="line-215"></span><p class="line862">There <a class="https" href="https://www.google.com/search?{google:acceptedSuggestion}oq=convert&amp;sourceid=chrome&amp;client=ubuntu&amp;channel=cs&amp;ie=UTF-8&amp;q=convert+from+bzr+to+git">are</a> <a class="https" href="https://astrofloyd.wordpress.com/2012/09/06/convert-bzr-to-git/">several</a> <a class="http" href="http://www.fusonic.net/en/blog/2013/03/26/migrating-from-bazaar-to-git/">useful</a> <a class="http" href="http://blog.timmattison.com/archives/2011/06/13/how-to-convert-from-bzr-to-git-on-debianubuntu/">recommendations</a> online for how to convert from Bazaar to Git. Here's one way that preserves tags and does a pretty good job for relatively simple Bazaar branches. <span class="anchor" id="line-216"></span><span class="anchor" id="line-217"></span><p class="line867"><span class="anchor" id="line-218"></span><span class="anchor" id="line-219"></span><span class="anchor" id="line-220"></span><span class="anchor" id="line-221"></span><span class="anchor" id="line-222"></span><span class="anchor" id="line-223"></span><span class="anchor" id="line-224"></span><pre><span class="anchor" id="line-1-11"></span>$ cd /some/place # parent directory of Bazaar branch <span class="anchor" id="line-2-3"></span>$ mkdir new-git-repo <span class="anchor" id="line-3-2"></span>$ cd new-git-repo <span class="anchor" id="line-4-1"></span>$ git init . <span class="anchor" id="line-5-1"></span>$ bzr fast-export --export-marks=../marks.bzr ../old-bzr-branch | git fast-import --export-marks=../marks.git <span class="anchor" id="line-6-1"></span>$ git checkout master</pre><span class="anchor" id="line-225"></span><span class="anchor" id="line-226"></span><p class="line862">Now the <tt class="backtick">new-git-repo</tt> directory is a Git repository with history equivalent to your old Bazaar branch. You should push it somewhere, and to ensure that everything is correct you should re-clone it locally to whatever final destination path you want to work in. <span class="anchor" id="line-227"></span><span class="anchor" id="line-228"></span><p class="line862">If you have several different Bazaar branches that form part of the same project, or if your Bazaar branches constitute packaging for a project whose upstream is in revision control elsewhere, then you may well want to do a more careful conversion. For this, <a class="http" href="http://www.catb.org/~esr/reposurgeon/">reposurgeon</a> is an excellent tool: it gives you a language for describing the transformations you want to make to your input branches, so you can run the migration several times with different tweaks before deciding that the result is the one you want to publish to the world. <span class="anchor" id="line-229"></span><span class="anchor" id="line-230"></span><p class="line862">Once you're ready to use Git by default for your project, you can configure this from <a class="https" href="https://launchpad.net/PROJECT/+configure-code">https://launchpad.net/PROJECT/+configure-code</a> (which is linked from the &quot;Configuration Progress&quot; section of the main project page on Launchpad). <span class="anchor" id="line-231"></span><span class="anchor" id="line-232"></span><p class="line867"> <h1 id="Deleting_a_Git_repository">Deleting a Git repository</h1> <span class="anchor" id="line-233"></span><span class="anchor" id="line-234"></span><p class="line874">In order to delete a Git repository, you need to follow these steps: <span class="anchor" id="line-235"></span><ul><li>go to the project <span class="anchor" id="line-236"></span></li><li>scroll down to the &quot;Code&quot; section <span class="anchor" id="line-237"></span></li><li><p class="line862">click on repository listed as &quot;lp:&lt;your-repository-name&gt;&quot; <span class="anchor" id="line-238"></span></li><li>on the right hand side click on &quot;Delete repository&quot; <span class="anchor" id="line-239"></span></li><li>confirm the deletion on the next page <span class="anchor" id="line-240"></span><span class="anchor" id="line-241"></span></li></ul><p class="line874">As an alternative you can also use &quot;lp-shell&quot; to delete the repository: <span class="anchor" id="line-242"></span><span class="anchor" id="line-243"></span><p class="line867"><span class="anchor" id="line-244"></span><span class="anchor" id="line-245"></span><pre><span class="anchor" id="line-1-12"></span>lp.load('path to repository').lp_delete()</pre><span class="anchor" id="line-246"></span><span class="anchor" id="bottom"></span></div><p id="pageinfo" class="info" lang="en" dir="ltr">Code/Git (last edited 2023-10-19 13:59:58 by <span title="jugmac00 @ 2001:67c:1560:8007::aac:c5c9[2001:67c:1560:8007::aac:c5c9]"><a class="interwiki" href="https://launchpad.net/~jugmac00" title="jugmac00 @ 2001:67c:1560:8007::aac:c5c9[2001:67c:1560:8007::aac:c5c9]">jugmac00</a></span>)</p> <div id="pagebottom"></div> </div> <div id="footer"> <p class="menu"> <a href="https://help.launchpad.net/Legal">Terms of use</a> | <a href="https://launchpad.net/feedback">Help improve Launchpad</a> | <a href="https://launchpad.net/faq">FAQ</a> | <a href="/RecentChanges">Recent Changes</a></p> <p> <a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/"> <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">Launchpad Help</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://canonical.com/" property="cc:attributionName" rel="cc:attributionURL">Canonical Ltd</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/">Creative Commons Attribution 2.0 UK: England &amp; Wales License</a>. <img alt="Creative Commons License" style="border-width:0;vertical-align:middle;" src="https://licensebuttons.net/l/by/2.0/uk/80x15.png" /></a> </p> <p>&copy; 2004-2019 <a href="https://canonical.com/" target="_blank">Canonical Limited.</a></p> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10