git clone repository into powershell azure function using console - azure

What is the right sintaxis for running git clone command on an Azure function powershell 7.0?
Im trying with: git clone <repo https>
and also adding the path at the end git clone <repo https> /.
i get the following error message:
`Command 'starter.cmd git clone https ...' was aborted due to no output nor CPU activity for 60 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.`
*Update:
Also tried with git clone https://username:password#github.com/username/repository.git
Cloning into ''...
fatal: unable to access 'https://github.com//.git/': URL using bad/illegal format or missing URL
I have'nt found any documenation on this... is it even possible?

I'd first ask what you're trying to achieve by doing this as it's a bit of an odd scenario and there may be a better way of cloning a repo as part of a pipeline and publishing the content with your Function.
If you really must go this route I would look at downloading the repo/branch content with Invoke-RestMethod/Invoke-WebRequest instead and unpacking to the underlying directory structure.
Invoke-WebRequest -Uri 'https://github.com/$owner/$repo/archive/$branch.zip' -OutFile '$repo.zip'
or using the .NET approach like Matthias pointed out in this response:
https://stackoverflow.com/a/48547954/12040634

Related

Pushing a respository I initialised with git init inside another repository to github

I am currently doing course called fullstackopen for which I created a repository on Github called fso and cloned it locally using ssh. Inside fso, I created directories for different parts(part1, part2) and created react projects inside them (using create-react-app). I pushed them to github without any problems.
For part3, the course asked to create a new repository for the backend(node js). I created this repo inside fso/part3 using git init and initialised a node app called phonebook. Now, when I tried to push it to Github, I got this:
enter image description here
So, I added my github repo using:
git remote add origin
After this when I tried to push again, I was prompted for my username and password but support for password authentication has been removed. I tried pushing using personal access tokens and got this:
enter image description here
Can I run the following in my part3/phonebook (phonbook-backend) directory?
git pull origin master git push origin master
I'm not sure if this would work, I dont want to lose my work.
Edit: i tried git pull origin main --allow-unrelated-histories and got this
pushing after this results in the same error
this is what my directory structure looks like locally. Im trying to push part3 to my github repo
Your last error is 'updates were rejected because the remote contains work'
This happens when your repository gets initialized with additional files like README or GITIGNORE. To resolve this, first you need to pull your changes from server, so you can use below command:
'git pull origin main --allow-unrelated-histories'
Then you can push your changes to server using below command:
'git push -f origin main'

Getting 'forbidden' pushing a nuget package in github

Much like this thread: Publishing and Consuming GitHub Package Repository with NuGet: Unable to load the service index error
I have the csproj correct, the nuget.config correct (same as in that thread, but for my username), and following the answer where the token has all the rights, and I do the dotnet nuget add source, and the dotnet nuget push (same formatting/syntax).
However, I always always get this:
warn: <username> does not have the correct permissions to execute 'CreatePackageVersion'
Forbidden https://nuget.pkg.github.com/(username)/ 687ms
error: Response status code does not indicate success: 403 (Forbidden).
I've tried with/without the -k (git token) in the dotnet nuget push, no effect. The --interactive that it recommends, doesn't change anything.
I'm running this in a standard command line in the \bin\Release\netstandard2.0\publish directory, after having published to that folder.
Did already restart computer even after adding appropriate csproj and nuget.config data. Also tried doing #username and username (my username with and without an at sign, since all docs have no actual username examples, many blackened out).
(I do want it to be public readable, already added source .../(username)/index.json).
Check the RepositoryUrl in your csproj. It should match the repository you're uploading packages to. You may also need to set PublishRepositoryUrl.

Git:Heroku Repository or object not found:

Here is the error message from Heroku master push command
Git LFS: (0 of 5 files) 0 B / 167.50 MB
batch response: Repository or object not found: https://git.heroku.com/xxxx-brushlands-xx267.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it
error: failed to push some refs to 'https://git.heroku.com/xxxx-brushlands-xx267.git'
Added a long text file to Git LFS (git for large files) and after that Heroku stopped working.
What might be the issue ?
A workaround:
git push heroku master --no-verify
This disables git-lfs pre-push hook. Metadata files are commited but binaries are not uploaded.
Then, as per upendra's answer, a buildpack can be used to download the files.
After alot of googling I found that the problem is with Heroku. If you are using Heroku, then Heroku doesn't support LFS and you have to look for alternatives.
I uploaded my long text file to dropbox and accessing it from there. Heroku should definitely look in to this issue.
I found a temporary solution to the problem of using Git LFS with Heroku. I am just putting it here just in case if people are still looking for it - https://github.com/git-lfs/git-lfs/issues/805
If that doesn't work, then try this out. This method worked for me - https://github.com/raxod502/heroku-buildpack-git-lfs

(remote rejected) master -> master (pre-receive hook declined), Push rejected, failed to compile Node.js app

I know that there's couple posts like this one, but solution of any of them works for me.
Here is what I receive when I go for git push heroku master:
Please support. Ignoring node_modules is not working.
Docpad app - package.json file is updated according to docpad's manual.
I also have Procfile set up as in the link above.
PS. I have tried to deploy docpad app via openshift, but while Im going with manual from http://docpad.org/docs/deploy/ I receive error at step 5.
The application 'appname' is configured for git reference deployments but the
artifact provided ('https://github.com/myusername/appname#master') is a url.
Please provide a git reference to deploy (branch, tag or commit SHA1) or
configure your app to deploy from binaries with 'rhc configure-app appname
--deployment-type binary'.
If I configure myapp to deployment-type binary it isnt working neither.
The plugin which heroku tries to install returned 404 and the installation fails due to that.
Verify that the plugin is indeed public and not something you have wrote or used locally.
There is no package with this name hosted on the registry you use.
Remove the line with "docpad-plugin-blah": "2" from your package.json file. That line was provided in the docs simply to show you how to install plugins, but there's no such plugin as blah.
"dependencies": {
"docpad": "6"
},
I strongly recommend that you read through the Getting Started on OpenShift to get an overview of the development workflow using Git.
That being said, and if you really meant to use git reference deployments and you know why you are using them, then read through the Managing Deployments section on the developers page of OpenShift and find out how to properly set up git reference deployments. For instance, 'https://github.com/myusername/appname#master' is not a valid git url and therefore it cannot be cloned.

Eclipse + git : clone over ssh not working

I've just installed Eclipse for PHP (Luna).
I'm trying to have the IDE to clone a git repository (bare) from URI.
So I did :
File > Import... > Projects from Git > Clone URI
First weird thing is I can't use SSH as the protocol (although it's in the list), and I need to use SFTP otherwise Eclipse says it can't connect.
I've given an URI of this type :
sftp://my_user#my_server_ip/path/to/my/repo.git
Then I selected my branches (tried selecting one or more master / HEAD)
Defined destination path, tried to check or uncheck Clone submodules.
Then it starts cloning.
Everything seems fine, until I get this error :
Git repository clone failed.
Cannot download 3d4d4abed8044e6d20c70ff4053e8af30713f0fe
Hitting the "Details >>" Button doesn't help more and basically says the same thing.
Now when I go to my destination folder I have nothing but the .git folder with objects and refs.
I thought maybe a data file was too big or something, so I checked on my server :
cd /path/to/my/repo.git
find ./ -name *3d4d4abed8044e6d20c70ff4053e8af30713f0fe*
# this outputs nothing, but taking a part of the hash :
find ./ -name *44e6d20c70ff4053*
# outputs : ./objects/3d/4d4abed8044e6d20c70ff4053e8af30713f0fe
Which seems absolutely weird to me because that's the exact same hash except for the few first characters :
3d4d4abed8044e6d20c70ff4053e8af30713f0fe
4d4abed8044e6d20c70ff4053e8af30713f0fe
And magically, these non-matching chars are "3d" which is the name of the folder containing the binary file.
I've tried cloning the project with a linux box :
git clone ssh://user#ip/path/to/project.git
It worked like a charm.
I've tried to clone another git repository (non-bare) with Eclipse, and this it asked me for my password, which I gave and then it said it couldn't connect to the server (?!) (I've tried giving a wrong password, and in this case it asks again for the password).
URI : sftp://my_user#my_server_ip/path/to/my/second_repo.git
ERROR : "An error occured when trying to contact sftp://....../second_repo.git. Possible reasons : Incorrect URL
And again, this exact same URI (except I replaced sftp with ssh) worked fine on a linux box.
cd /tmp/
git clone ssh://my_user#my_server_ip/path/to/my/second_repo.git
>> Cloning into second_repo
>> ...
Any idea on what to do from there?
I don't get why one project starts to checkout and for the other (which is on the same server but is just "non-bare") a connection error happens?
Alternatively, could anyone point me an IDE supporting PHP, HTML, JS, and Git ? (please do it as a comment, not an answer unless it's really elaborated).
Thank you.
EDIT :
I have my answer to my second question : to clone, EGit is looking for an "objects" folder in the remote repository, so obviously that couldn't work with a "non-bare" repo.
I had similar problem with Eclipse Luna 64-bit for Java, so i downgraded to Kepler, please give it a try and let me know if it helps.
In my case the proble was the url. Because not was a project git. Example
I was trying with : https://github.com/pkainulainen/spring-mvc-test-examples/tree/master/controllers-unittest
but the previous link was wrong, because was son of the father project
the father proyect was: https://github.com/pkainulainen/spring-mvc-test-examples

Resources