Skip to content

TIL: useful git alias for AUR

In your git config, you can define URL aliases which can be useful for installing packages from the AUR:

Add this to your ~/.gitconfig:

[url "https://aur.archlinux.org/"]
    insteadOf = aur://

And you can now clone repositories from the AUR (to get PKGBUILDs and patches and stuff) with:

git clone aur://interesting-software

TIL, and it's something I wanted to share :)

332 points15 comments
Open on Reddit
About this post
Posted
Archived
Score
332 · 100% up
Kind
Text
ID
5vdcbc

Author

8
posts
36
comments
5
media
View profile

16 comments

Oh, neat. I never realized git had these sorts of aliases. Obviously useful for more than just the AUR.

38 points

Even better in combination with pushInsteadOf:

[url "https://github/"]
    insteadOf = "gh:"
[url "git@github.com:"]
    pushInsteadOf = "gh:"

git clone gh:foo/bar.git clones the repo and sets it up to pull over HTTPS (no auth needed if public repo) and push over SSH :)

47 points

Combining the two:

[url "https://aur.archlinux.org/"]
    insteadOf = "aur:"
[url "ssh+git://aur4.archlinux.org/"]
    pushInsteadOf = "aur:"
9 points

Yeah, when I found out about it today, I immediately created aur:// and gh:// for github, and workgh:// as a root alias for projects under my work's github organization.

18 points
  1. Why burden yourself with the slashes? Just remove them from the insteadOf to make git clone aur:whatever work :)

  2. An alternative method that I use is to put a host in the SSH config:

     Host aur
     HostName aur.archlinux.org
     User aur
     IdentityFile ~/.ssh/redacted-aur
    

Only works if you’ve got SSH set up for AUR, of course, e. g. because you also publish some packages.

29 points

I prefer this version:

[url "ssh+git://aur@aur.archlinux.org/"]
    insteadOf = "aur:"
5 points

Another handy tip, if you just want to build the latest package release (as most people probably do) you can add --depth=1 after git clone to download just the latest version and avoid wasting ~~time/~~bandwidth downloading the whole history.

Edit: After testing it turns out this isn't worth it unless you are really tight on bandwidth or have a terrible connection and will probably just be about 1/10th of a second slower for most people.

4 points

That should basically make no difference for the AUR repos though. Might even make it take longer because it forces the server side to recompute the deltas.

5 points

So I ran some tests (downloaded some packages from aur about 20 times for each setting) and it seems you are right. For an example: google-chrome takes an average of 0.94 seconds to download the full history and 1.1 seconds with --depth=1. The filesize of the resulting clone goes from 196K (329 objects) down to 132K (6 objects) so bandwidth/disk space is the only improvement, but with such small sizes I doubt it really matters.

3 points

cool, this would also make it easier to get aur packages on non-arch systems (forced to use *buntu at work)

1 points
unknown author1 hidden

Deleted before we saved it.

-1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.