Issue with GIT command - linux

I am trying to execute git clone command to clone source code from github repository. I am using 2.11.1 version. command I run is
git clone https://username:password#github.com/repository.git ./localpath
This works fine at windows machine. But when I am executing from linux machine command is removing # and throwing error. Execution failure is like
git clone https://username:passwordgithub.com/repository.git ./localpath Cloning into './localpath'...
error: Couldn't resolve host username:passwordgithub.com while accessing
Could someone help me to fix this?

Register your ssh-keygen generated id to Github so it would not prompt you for password.
$ ssh-keygen
No need to enter pass-phrase. Output your public key, then copy it to github
$ cat ~/.ssh/id-rsa.pub
But, if you really want to go that route.
Enclose them in a single quotation, or do them like below.
#!/bin/bash
REPO='https://username:password#github.com/repository.git'
LOCAL_PATH='path/to/wherever'
git clone "$REPO" "$LOCAL_PATH"
Note: Use double quotations for variables

Related

No access to remote repository

I am deploying my node.js app.
I am using git hooks and creating a remote repository.
In the image below you can see that i have added the remote 'adiproduction' to which i will push from my local repo.
Below i am pasting the image of content in post-receive file of hooks.
Following is the error when i try to push my code on 'adiproduction' remote.
ubuntu#35.154.65.179: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Edit:
I tried running the ssh -Tv ubuntu#35.154.65.179 command. And i got the following output.
try to run the code with "sudo"
sudo helps you to run the command with root privilege
and secondly, if you dont want use sudo so please set the ssh key on your git account, this link will helps you to set the ssh key-
'https://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix/'
and lastly if above solution not helps then please delete the current repository and try to clone again useing following command with ssh clone link-
git clone -b
thank you

cloning a repository in gitkraken from url ssh invalid

I'm quite new to Linux and I have some trouble using GitKraken (in Windows I use SourceTree). I want to clone a repository that is on my NAS. Unfortunately, when I try to clone it says: "Configured SSH key is invalid. Please confirm that it is properly associated with your Git provider". In Preferences>Authentication I have checked (default) Use Local SHH agent.
If I clone the rep from the terminal with git clone command it asks for the password and everything is ok.
Any suggestion?
Alex
I had the same error message in my GitKraken.
I followed carefully all the steps of "Set up SSH for Git on XXX" (Windows in my case) and managed to make it work.
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
Not sure it exactly applies to your case, but maybe it can guide you to the right direction.

Git did not exit cleanly (exit code 1)

I can't push and I already tried all solution in this question. I'm using Windows10 and TortoiseGit.
I generated my SSH key with PuTTYgen and I already tried to replace the key in case my older was corrupted. When I try with git bash I got this error:
$ git fetch -p Permission denied (public key).
fatal: Could not read from remote repository. Please make sure you
have the correct access rights and the repository exists.
In TortoiseGit I get:
git did not exit cleanly (exit code 1)
For My case i did 3 steps to achieve the sucessful build.
revert all the local changes if any (or just keep a copy of it in case you need it for future use)
Do a git clean up, do a pull and check the logs for error
GO to the git bash option and the error i was getting in log in above stem (i my case )
as "error: cannot lock ref and the branch details", so in the git bash i ran the following command
git update-ref -d 'Branch_name'
For example if the error was something like
**
ISSUE
**error: cannot lock ref 'refs/remotes/origin/EXMPLEISSUE/EXAMPLE-1011_DEMO_web_interface_DOES_NOT_GET_GIT_UPDATE':
Then i ran following command
git update-ref -d 'refs/remotes/origin/EXMPLEISSUE/EXAMPLE-1011_DEMO_web_interface_DOES_NOT_GET_GIT_UPDATE'
We have to ensure all the error in logs to be solved similarly before getting a successful pull by doing git update-ref -d 'Branch_name' and finally i can get the take the successful pull from git.

GIT Pull using Ubuntu 16.04.2 LTS

I want to be able to pull down my source code from GitHub automatically, but currently doing it manual using the process below.
Currently i have to do this by going
$ sudo -i
Then I CD to my directory, once in I run the following command
$ git pull origin master
the command then asks for me to enter my key password
Enter passphrase for key '/root/.ssh/id_rsa':
This then pulls the latest code down from GitHub.
A beginning note: does your repo really need to be pulled as root? Why? It's probably not a good idea to be doing that.
Github supplies https pull links that anyone can use to pull without needing a key. So, we can add another remote, used specifically for this purpose, that pulls using the https link.
git remote add autopull https://github.com/<user>/<repo>.git
Now you can change your pull command to:
git pull autopull master
From there, you can put it in .profile, .bash_profile, .bashrc, or maybe even a cron script. You haven't specified how you want to automate it, though, so I can't give any specific examples.
It should be noted that this can only work for public repositories. If this is a private repository, you should create another keypair that has no passphrase required. If it isn't your default keypair you can make use of a trick.
ssh-agent bash -c 'ssh-add /path/to/yourkey; git pull autopull master'
Or another answer to the same question:
GIT_SSH_COMMAND='ssh -i /path/to/yourkey' git pull autopull master

git autodeploy script within post-receive hook on ubuntu

I have an autodeploy bash script to get updated repo to /tmp in 'post-receive' hook on gitosis
#!/bin/bash
PWD=$PWD
REPO_NAME=${PWD##/*/}
cd /tmp
git clone git#atom-desktop:$REPO_NAME
But anytime when I push repository I got error like this:
Host key verification failed.
fatal: The remote end hung up unexpectedly
error: hooks/post-receive exited with error code 128
How to cope with that ?
You can simply do:
git clone --local $REPO_NAME
As git also supports cloning from local directories:
git-clone
For local respositories, also
supported by git natively, the
following syntaxes may be used:
/path/to/repo.git/
file:///path/to/repo.git/
These two syntaxes are mostly
equivalent, except the former implies
--local option.
Sounds like there is a key mismatch in the SSH connection from wherever /tmp is and atom-desktop. What happens if you try to SSH from the machine that /tmp is located at to atom-desktop?

Resources