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?
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
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. ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for wget you need additional option :
--auth-no-challenge send Basic HTTP authentication information
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.