How to set proxy using libgit2sharp? - proxy

I use libgit2sharp clone and faced "failed to send request: The operation timed out" when I am using corporate networking.
If I use my own 3G networking, it can clone successfully.
But after I use git config in command line and I can clone repository by command line, I still can't clone repository by the code....
could everyone teach me how to set proxy in the code or how to use this lib in proxy environment?
Thanks!

Related

Need to clone repository after SSH into server using TeamCity

I have a job that SSH into server and after that I need to git clone repository into this server that I SSHed before. How could I do it?
I set VCS checkout mode on agent, and set custom path
I think there are two ways to achieve it:
Use SSH Exec runner to execute git clone on remote machine
Use SSH Upload to upload previously cloned repository to remote machine
First one is faster but you need to take care of git auth on remote machine.

Using .PAC proxy configuration file with Git

I tried to clone a repo from Git within my corporate network and i got the below message in git bash terminal.
"$ git clone https://github.com/planetoftheweb/angulardata.git
Cloning into 'angulardata'...
fatal: unable to access 'https://github.com/planetoftheweb/angulardata.git/': Fa
iled connect to github.com:1080; No error"
When I checked my internet LAN settings, I could see that we use a .pac configuration file in the format "http://xxx.abcdefg.net/xyz-pqrst.com/xyz.pac".
Can anyone help me to setup this kind of proxy in git bash terminal?
I refered other questions regarding this matter and couldn't find one which helps me.

Git how to access repository Windows local machine?

I installed Git for Windows in order to clone and pull a project hosted on a remote Linux server.
In my repository (D:/repositories/my-project) I launch the following commands
git clone server#192.168.56.101:/var/www/web/my-project/.git
git pull origin master
So far so good. I pull the project files whenever modifications are applied on the server.
But now I'd like to pull or push from the remote server to my local repository.
I tried many things but I can't figure out how to access the repository located on my local machine.
Things like:
git pull duddy#my-pc:/d/repositories/my-project/.git master
just doesn't work, Git says:
ssh: Could not resolve hostname my-pc: Name or service not known
fatal: Could not read from remote repository.
Can someone helps me ?
First things first, I would recommend you try simply running git pull.
If this doesn't work, try running git remote -v and check to make sure that the URL for your server is listed as an origin (server#192.168.56.101:/var/www/web/my-project/.git).
Your issue is that you are inputting the URL for your local repository in your attempt to git pull.
I suggest reading the git-pull documentation to learn more about how pull works.
Basically, you need to have some service at your workstation which serves the requests. There are following options (I did not try most of them myself, just making it up from what I know):
use the windows file access. This is the easiest to setup at the windows workstation - just share the repository folder. The Linux side should somehow be able to mount windows shares (like described, for example, here: https://wiki.ubuntu.com/MountWindowsSharesPermanently). If you manage to mount your \\my-pc\repo to some /mount/my-pc-repo, then you can access it as file:///mount/my-pc-repo.
run git daemon at windows. Set up instructions are available at SO (for example, https://stackoverflow.com/a/2275844/2303202) and it pretty straightforward, but it does not have any authentication and in most cases it is reasonable to use it only for reading, so you will not be able to push to the workstation, only fetch.
set up ssh daemon and access through ssh authentication with read-write access. Git for windows installation contains the needed software (the sshd.exe binary, it is there at least for Git for Windows 2.6.0), probably there is a way to utilize it but I could not find it quickly.
set up HTTP(S) service at your workstation. I don't know if it is possible to do only with Git for Windows (it might be, with some perl module which happen to be included with it), or you should use some other software.

Xcode - Authentication failed error when adding repository with SSH auth

I am trying to add repository via Xcode > Settings > Accounts and I am stuck on the proper address. Address of our repo is quite simple: my.domain.com:port/project-name. Authentication via SSH Keys. Could someone help me to understand what's going on here? See screenshot below.
By the way running git clone git+ssh://git#my.domain.com:port/project-name works fine.
EDIT
Running git clone without git+ssh//
git clone git#my.domain.cz:2222/project-name
or
git clone git#my.domain.cz:22/project-name
is giving me same error:
ssh: connect to host my.domain.cz port 22: Connection refused
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
Xcode accepts just ssh://git#my.domain.cz:2222/project-name.
The git protocol is somehow redundant in this case. Raw git tools don't have a problem with it, but Xcode does not like it for some reason.
It always fails for me when I use existing ssh keys.
I created a new ssh key pair through Xcode and uploaded the public key to the git server (in my case, Phabricator), and it works.

configuring gitlab project for https access

I have created a project in gitlab called git clone test. In the advanced setting feature i can see that cloning can be done only by git clone git#xxx.xx.xxx.xxx:git_clone_test.git. I want to clone using https protocol.
So i tried the following
git remote set-url origin https://xxx.xx.xxx.xxx/git_clone_test.git
verified
git remote -v
origin https://xxx.xx.xxx.xxx/git_clone_test.git (fetch)
origin https://xxx.xx.xxx.xxxgit_clone_test.git (push)
[edit]: gitlab.yaml has https turned on on port 443
But the following command
$ env GIT_SSL_NO_VERIFY=true git clone https://xxx.xx.xxx.xxx/git_clone_test.git
Cloning into 'git_clone_test'...
Gives the error:
fatal: https://xxx.xx.xxx.xxx/git_clone_test.git/info/refs not found: did you run git update-server-info on the server?
I think problem lies in the fact that gitlab does not allow me to change git clone field in advanced settings. Perhaps a server setting needs to change?
We are using gitlab (git+gitolite) on nginx server.
We are trying to use https access as this server is behind a firewall, and the client cannot clone it. They can see the web interface and and download files from that interface, but git operations pose a problem. We think that changing access to https might solve this problem
Any pointers would help
thanks
Sameer
It looks like you have forgotten some small changes within your gitlab.yml configuration.
To use HTTPS you also have to change the config file as follows
# https://github.com/gitlabhq/gitlabhq/blob/6-4-stable/config/gitlab.yml.example#L19-L20
port: 80
https: false
change to:
port: 443
https: true
We solved this issue by upgrading to latest version of gitlab which supports https access in a pretty straightforward manner

Resources