Diff for "Code/Git"

Not logged in - Log In / Register

Differences between revisions 3 and 16 (spanning 13 versions)
Revision 3 as of 2015-04-30 02:05:13
Size: 6289
Editor: cjwatson
Comment: update support status a little
Revision 16 as of 2015-06-30 02:21:19
Size: 6483
Editor: cjwatson
Comment: present tense
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
Launchpad features experimental support for hosting [[http://git-scm.com/|Git]] repositories. This is distinct from the [[Code/Imports|code import]] facility that Launchpad has included for many years; it will shortly be possible to host Git repositories on Launchpad directly. Launchpad supports hosting [[http://git-scm.com/|Git]] repositories. This is distinct from the [[Code/Imports|code import]] facility that Launchpad has included for many years; it is now possible to host Git repositories on Launchpad directly.
Line 13: Line 13:
As of the end of April 2015, a reasonably complete basic version of Git hosting support is live on our "qastaging" site. This means: As of May 2015, a reasonably complete basic version of Git hosting support is live on Launchpad production. This means that you can:
Line 15: Line 15:
 * all changes made will be reset - this is not yet a persistent hosting service, but is strictly for experimenting and finding bugs in Launchpad
 * the URL format is not guaranteed to be stable
 * everything is on qastaging.launchpad.net and git.qastaging.paddev.net, rather than on the main launchpad.net site
 * the hosting backend is still quite basic and may have scaling problems

Within these constraints, you can:

 * push Git repositories to qastaging over SSH
 * push Git repositories over SSH
Line 24: Line 17:
 * see summary information on repositories and the branches they contain in the Launchpad web UI on qastaging  * see summary information on repositories and the branches they contain in the Launchpad web UI
Line 26: Line 19:
 * propose merges from one branch to another, including in a different repository, provided that they are against the same project or package (registering merge proposals currently requires using the webservice, and preview diffs don't yet work; both will be fixed soon)

Just don't keep the only copy of your repository on qastaging!
 * push and clone private repositories, if you have a commercial subscription to Launchpad
 * propose merges from one branch to another, including in a different repository, provided that they are against the same project or package
Line 32: Line 24:
Our top priority is to polish things up so that this can land on Launchpad production, and to this end we appreciate your feedback on any bugs you find. Here's a short list of known bugs that you don't need to tell us about:

 * finding the URL for a new repository after you've pushed it is hard
Line 38: Line 26:
 * merge proposals (these are very heavily used by many teams, including Launchpad itself, so are the top feature priority)
Line 45: Line 32:
Here's a short list of known bugs that you don't need to tell us about:

 * the interface for registering merge proposals is very rough
Line 48: Line 39:
[url "git+ssh://USER@git.qastaging.paddev.net/"]
        insteadof = lpqas:
[url "git+ssh://USER@git.launchpad.net/"]
        insteadof = lp:
Line 51: Line 42:
This allows you to type `git clone lpqas:REPOSITORY` instead of `git clone git+ssh://git.qastaging.paddev.net/REPOSITORY`.  (Of course, when we add Git support to production we will update this documentation to recommend `lp:` instead.) This allows you to type `git clone lp:REPOSITORY` instead of `git clone git+ssh://git.launchpad.net/REPOSITORY`.
Line 54: Line 45:

For personal repositories, you can also add: {{{
[url "git+ssh://USER@git.launchpad.net/~USER/+git/"]
        insteadof = lpme:
}}}
Line 58: Line 54:
$ git clone lpqas:PROJECT $ git clone lp:PROJECT
Line 61: Line 57:
For example, `git clone lpqas:launchpad` fetches Launchpad itself. For example, `git clone lp:launchpad` fetches Launchpad itself (or will once we've finished converting it to Git!).
Line 70: Line 66:
$ git remote add lpqas lpqas:PROJECT $ git remote add origin lp:PROJECT
Line 74: Line 70:
$ git remote add lpqas lpqas:~USER/PROJECT $ git remote add origin lp:~USER/PROJECT
Line 78: Line 74:
$ git push lpqas my-changes $ git push origin my-changes
Line 85: Line 81:
 * https://code.qastaging.launchpad.net/~OWNER/PROJECT/+git/REPOSITORY
   This identifies a repository for an upstream project.

 * https://code.qastaging
.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE/+git/REPOSITORY
   This identifies a repository for a source package in a distribution.

 * https://code.qastaging
.launchpad.net/~OWNER/+git/REPOSITORY
  
This identifies a "personal" repository with no particular connection to any project or package.
  https://code.launchpad.net/~OWNER/PROJECT/+git/REPOSITORY:: This identifies a repository for an upstream project.
  https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE/+git/REPOSITORY:: This identifies a repository for a source package in a distribution.
  https://code.launchpad.net/~OWNER/+git/REPOSITORY:: This identifies a "personal" repository with no particular connection to any project or package.
Line 96: Line 87:
 * https://code.qastaging.launchpad.net/PROJECT
   This is the default repository for an upstream project.

 * https://code.qastaging
.launchpad.net/DISTRIBUTION/+source/SOURCE
  
This is the default repository for a source package in a distribution.
  https://code.launchpad.net/PROJECT:: This is the default repository for an upstream project.
  https://code.launchpad.net/DISTRIBUTION/+source/SOURCE:: This is the default repository for a source package in a distribution.
Line 104: Line 92:
 * https://code.qastaging.launchpad.net/~OWNER/PROJECT
   This is an owner's default repository for an upstream project.

 * https://code.qastaging
.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE
  
This is an owner's default repository for a source package in a distribution.
  https://code.launchpad.net/~OWNER/PROJECT:: This is an owner's default repository for an upstream project.
  https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE:: This is an owner's default repository for a source package in a distribution.
Line 111: Line 96:

= Converting from bzr to git =

There [[https://www.google.com/search?{google:acceptedSuggestion}oq=convert&sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=convert+from+bzr+to+git|are]] [[https://astrofloyd.wordpress.com/2012/09/06/convert-bzr-to-git/|several]] [[http://www.fusonic.net/en/blog/2013/03/26/migrating-from-bazaar-to-git/|useful]] [[http://blog.timmattison.com/archives/2011/06/13/how-to-convert-from-bzr-to-git-on-debianubuntu/|recommendations]] online for how to convert from bzr to git. Here's one way that preserves tags and does a pretty good job for relatively simple bzr trees.

{{{
$ cd /some/place
$ bzr branch old-bzr-branch new-git-repo
$ cd new-git-repo
$ git init .
$ bzr fast-export
$ bzr fast-export --export-marks=../marks.bzr | git fast-import --export-marks=../marks.git
}}}

Now the `new-git-repo` directory is kind of both a bzr repo and a git repo. You'll need to explicitly `git add` back all the files and directories you want to keep. Then I recommend you push the git repo somewhere and re-clone it locally to whatever final destination path you want to work in.

Launchpad Help > Code > Git

Overview

Launchpad supports hosting Git repositories. This is distinct from the code import facility that Launchpad has included for many years; it is now possible to host Git repositories on Launchpad directly.

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.

What's supported?

As of May 2015, a reasonably complete basic version of Git hosting support is live on Launchpad production. This means that you can:

  • push Git repositories over SSH
  • clone repositories over git://, SSH, or HTTPS
  • see summary information on repositories and the branches they contain in the Launchpad web UI
  • follow links from the Launchpad web UI to a full-featured code browser
  • push and clone private repositories, if you have a commercial subscription to Launchpad
  • propose merges from one branch to another, including in a different repository, provided that they are against the same project or package

What will be supported?

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:

  • useful subscriptions (currently only attribute change notifications work, which are not usually very interesting in themselves)
  • RSS feeds
  • mirroring
  • webhooks
  • an integrated code browser

Here's a short list of known bugs that you don't need to tell us about:

  • the interface for registering merge proposals is very rough

Configuring Git

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 ~/.gitconfig and add these lines, where USER is your Launchpad username:

[url "git+ssh://USER@git.launchpad.net/"]
        insteadof = lp:

This allows you to type git clone lp:REPOSITORY instead of git clone git+ssh://git.launchpad.net/REPOSITORY.

The rest of this documentation assumes that you have configured Git this way.

For personal repositories, you can also add:

[url "git+ssh://USER@git.launchpad.net/~USER/+git/"]
        insteadof = lpme:

Getting code

You can fetch the default repository for a project like this:

$ git clone lp:PROJECT

For example, git clone lp:launchpad fetches Launchpad itself (or will once we've finished converting it to Git!).

To keep your local clone up to date, run:

$ git pull

Pushing code

You can add a "remote" to your repository like this, if you own the project:

$ git remote add origin lp:PROJECT

Or like this (where USER is your Launchpad username), if you do not own the project:

$ git remote add origin lp:~USER/PROJECT

Now, you can push a branch using a command such as this:

$ git push origin my-changes

Repository URLs

Every Git repository hosted on Launchpad has a full "canonical" 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):

https://code.launchpad.net/~OWNER/PROJECT/+git/REPOSITORY
This identifies a repository for an upstream project.
https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE/+git/REPOSITORY
This identifies a repository for a source package in a distribution.
https://code.launchpad.net/~OWNER/+git/REPOSITORY
This identifies a "personal" repository with no particular connection to any project or package.

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 "default repositories". A repository can be the default for a target, in which case it has one of these forms:

https://code.launchpad.net/PROJECT
This is the default repository for an upstream project.
https://code.launchpad.net/DISTRIBUTION/+source/SOURCE
This is the default repository for a source package in a distribution.

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:

https://code.launchpad.net/~OWNER/PROJECT
This is an owner's default repository for an upstream project.
https://code.launchpad.net/~OWNER/DISTRIBUTION/+source/SOURCE
This is an owner's default repository for a source package in a distribution.

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.

Converting from bzr to git

There are several useful recommendations online for how to convert from bzr to git. Here's one way that preserves tags and does a pretty good job for relatively simple bzr trees.

$ cd /some/place
$ bzr branch old-bzr-branch new-git-repo
$ cd new-git-repo
$ git init .
$ bzr fast-export 
$ bzr fast-export --export-marks=../marks.bzr | git fast-import --export-marks=../marks.git

Now the new-git-repo directory is kind of both a bzr repo and a git repo. You'll need to explicitly git add back all the files and directories you want to keep. Then I recommend you push the git repo somewhere and re-clone it locally to whatever final destination path you want to work in.

Code/Git (last edited 2023-10-19 13:59:58 by jugmac00)