Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using git archive with stash git repo - http protocol

Garret Pick February 27, 2013

Hello,

We've been using 'git archive' with our git repos hosted under stash and are considering switching from the ssh to http(s) protocol.

git archive --format=tar --remote=ssh://<stash server>:7999/<PROJECT>/<repo>.git <branch>:<directory>/ | tar xf -

It appears this isn't supported with the http URL:

fatal: Operation not supported by protocol.

Does anyone know if this a limitation of git or of the way stash is servering the repos?

6 answers

1 accepted

1 vote
Answer accepted
Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2013

Hi Garrett,

It's a limitation of the git 'smart HTTP' protocol. You can however install the Stash ARchive Plugin from the Marketplace. That plugin adds a 'Download' button to the web interface, but also allows you to create and download an archive zip or tgz for a given branch over HTTP directly. Have a look at https://marketplace.atlassian.com/plugins/com.atlassian.stash.plugin.stash-archive for details.

Cheers,

Michael

1 vote
Theo Dickinson September 1, 2014

The only combination I could get to work was adding a few arguments to curl.

curl --user deploy:password -G http://scm-repo.company.com.au:7990/projects/MISSION/repos/webapp/browse/build.xml -d at=refs/tags/1.3.3 -d raw > build.xml

Hope that helps somebody ( I'm using stash v3.2.4. ).

0 votes
SUMEET GARG May 9, 2013

Hi,

I do not have a strong argument in favour of why I require a sub-directory download command, except that we are shifting from Accurev to Git/Stash. Such options were available in Accurev and we need to adapt to how Git/Stash commands work. Some of our repos are quite bulky, so cloning is not the best option. But we will use it if it comes to that. At this point, I am collecting information what all we would need to change. If need be, I will raise an issue in Stash Archive plugin. Having said that, downloading a single file option does solve a majority of the problem.

Thanks

Sumeet

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2013

Hi Sumeet,

I suspected that might be the case. Git, and DVCS in general, doesn't lend itself to having a single large repository, especially if there are large binary files involved. You either get the whole repository or nothing. In some instances you might be better of splitting a single repositories into multiple sub-repositories to make such things more manageable. It's not an easy change, and you have to decide how best to manage dependencies between those repositories, but it might be something to think about if you find a single repository unwieldy.

Let me know if you have any more questions about the differences between Accurev and Git.

Cheers,

Charles

0 votes
SUMEET GARG May 8, 2013

Hi,

curl command works! Thanks.

Is there a similar way to download a sub-directory (again not clone everything, just a sub-directory with complete path), just like we did with the file?

Thanks

Sumeet

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2013

Hi Sumeet,

At this point you're on your own. I start wonder what you're trying to do? Personally at this point you're better off either just cloning, Git is super-quick, or using the archive plugin. Is there any reason why you just want the sub-directory? Is your Git repository very large and that isn't an option?

Cheers,

Charles

TimP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2013

Hi Sumeet,

git-archive supports specifying a particular path or paths to include in the downloaded zip/tarball, but as mentioned above only supports SSH.

If you really want to be able to download just a subdirectory over http, I'd recommend contributing to the Stash Archive plugin https://bitbucket.org/atlassian/stash-archive (or failing that raising an issue in it) to restrict the downloaded archive to particular files.

cheers,

Tim

0 votes
SUMEET GARG May 7, 2013

Michael,

I get the same html file as output. The file has username and password fields. I tried the exact command as you told.

$ wget --user=user --password=pass https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw
--2013-05-08 09:23:53--  https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw
Resolving stash.pv.com... 172.16.0.29
Connecting to stash.pv.com|172.16.0.29|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://stash.pv.com/login [following]
--2013-05-08 09:23:53--  https://stash.pv.com/login
Connecting to stash.pv.com|172.16.0.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6038 (5.9K) [text/html]
Saving to: `promote_jenkins_config.sh?raw'

100%[============================================================================================>] 6,038       --.-K/s   in 0s

2013-05-08 09:23:58 (31.2 MB/s) - `promote_jenkins_config.sh?raw' saved [6038/6038]

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2013

Hi Sumeet,

I tried the above and also got HTML instead of a file. If I looked at the contents in a browser I could see it was the login page.

Part of the problem is that wget doesn't send the basic authentication headers, and we are redirecting the login page. You can fix that by using curl:

curl --user user:pass https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw > promote_jenkins_config.sh

Cheers,

Charles

Stefan Saasen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2013

Hi Sumeet,

With wget you would have to use the "--http-user" and "--http-pasword" options instead of "--user"/"--password" in order to use basic authentication.

Cheers,

Stefan

Stefan Saasen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2013

Hi Sumeet,

Actually I think you need to follow Charles' advice of using curl. Even with "http-user" wget doesn't work as expected :(

Cheers,

Stefan

pgmvva June 3, 2020

for wget you need additional option :

--auth-no-challenge send Basic HTTP authentication information

0 votes
SUMEET GARG May 7, 2013

Michael,

Instead of the download button, does it work via command line. I want a clean file without any html tags. Something like wget https://stash.pv.com/projects/PROJECT/repos/REPO/browse/PATH/FILE.EXT. If I try it I get a file with html tags. How to get clean file as it exists in its original form.

Thanks

Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 7, 2013

The 'Download' button can be used to download a snapshot of an archive of the repository. It sounds like you just want to download a single file?

You should be able to use the url you mentioned, just append a ?raw to it to get a version without markup.

wget --user=username --password=pwd https://stash.pv.com/projects/PROJECT/repos/REPO/browse/PATH/FILE.EXT?raw

should do the trick.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events