简体   繁体   中英

Modify the url automatically when using git clone

JHBuild uses the git protocoal instead of https for cloning the files. I am working in a proxy environment which prevents the cloning using the git protocol.

git url of sample gnome repo : git://git.gnome.org/gnome-common

http url of sample gnome repo: http://git.gnome.org/ browse /gnome-common.

Is there any way to transform the git url to https format automatically when JHBuild executes the clone command.

The gnome moduleset defines git.gnome.org as using git:// but this can be changed in the jhbuildrc file.

Add the following line in jhbuildrc.

repos['git.gnome.org'] = ' http://git.gnome.org/browse/ '

The file is present usually in ~/.config. Create jhbuildrc file if not present.

If you can't clone a repository with a git:// url because of a proxy or firewall, here is a little git configuration that will force git to use http:// even when you'll type git:// URL.

git config --global url."http://".insteadOf git://

With this command, it will add the following lines in you .gitconfig :

[url "http://"]   
    insteadOf = git://

That way, you don't have to care about using git:// or http:// when you are cloning repo, both urls will work.

Maybe a well known tweak but discovered it lately...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM