[SOLVED] Git - how to choose which account to commit to?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have account on both Github and Gitlab with the same username and email, how do i choose where i want to commit and push to. i want to use Gitlab and i don't want anything to be on Github. is there a way to do so?
Yes, there is. Gitlab has quite good documentation on that subject. The exact procedure depends on your specific use case. Is it an existing repository where or does it need to be created first? Which method do you want to use, SSH or HTTPS? Is it your repository? See the provided link and let us know if you get stuck.
Yes, there is. Gitlab has quite good documentation on that subject. The exact procedure depends on your specific use case. Is it an existing repository where or does it need to be created first? Which method do you want to use, SSH or HTTPS? Is it your repository? See the provided link and let us know if you get stuck.
With SSH you will have to create a private/public key pair and (probably) upload the public key to your Gitlab account account, the exact procedure should be in the documentation. With HTTPS you will (probably) have to enter your username and password every time you push changes to your repository. I have never used HTTPS, just SSH.
Here is the documentation on how to setup SSH access with Gitlab.
I normally use origin for source name but I *think* you can choose it freely. The <repository-path> depends on whether you access via HTTPS or SSH. I am not familiar with Gitlab but there is probably a field (while setting up the remote repo in your browser) which you can copy paste with the correct value, after you select your desired access method. At least that is how it works on "notabug.org", which is my online repo of choice. It should be a similar procedure on Gitlab.
I normally use origin for source name but I *think* you can choose it freely. The <repository-path> depends on whether you access via HTTPS or SSH. I am not familiar with Gitlab but there is probably a field (while setting up the remote repo in your browser) which you can copy paste with the correct value, after you select your desired access method. At least that is how it works on "notabug.org", which is my online repo of choice. It should be a similar procedure on Gitlab.
i did what the site says to generate the ssh key i generated RSA key 2048 bits and adding the key to gitlab site but on the step where verify if everything is working
Code:
ssh -T gitlab@gitlab.com
using my username@gitlab.com and when it asks "Are you sure you want to continue connenting" i type yes and it gives error saying permission denied (publickey)
the HTTPS method is working though, i already pushed 2 files successfully.
... when it asks "Are you sure you want to continue connenting" i type yes and it gives error saying permission denied (publickey)
First, make sure that you uploaded the public key and not the private key. Then take a look at this post for possible error sources when dealing with SSH.
My guess at this point is, that you named your key when you created it. You should create an SSH configuration file $HOME/.ssh/config. It should look like this:
First, make sure that you uploaded the public key and not the private key. Then take a look at this post for possible error sources when dealing with SSH.
My guess at this point is, that you named your key when you created it. You should create an SSH configuration file $HOME/.ssh/config. It should look like this:
Notice, that you cannot use the $HOME variable inside the configuration file.
according to the website i did this (with my email in the end)
Code:
ssh-keygen -t rsa -b 2048 -C "email@example.com"
then i did
Code:
cat ~/.ssh/id_rsa.pub
then copied it and pasted it gitlab -> settings -> ssh keys -> add ssh keys
then website said to test it
Code:
ssh -T git@gitlab.com
then i got an output something like this
Code:
The authenticity of host 'gitlab.com (35.231.145.151)' can't be established.
ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.com' (ECDSA) to the list of known hosts.
git@gitlab.com: Permission denied (publickey).
i saw 1 video on youtube the person did the exact same thing he didn't get error.
pretty sure .pub file is a public key
In your earlier post you said that you replaced "git" with your username, however, this has to be executed verbatim:
Code:
ssh -T git@gitlab.com
Do NOT replace anything. I just created a dummy account in gitlab, pasted my SSH key and after clicking "Add Key" everything worked. You could try, just to be sure:
Code:
ssh -i "$HOME/.ssh/id_rsa" -T git@gitlab.com
If you named your key anything else then "id_rsa" then use that name instead.
In your earlier post you said that you replaced "git" with your username, however, this has to be executed verbatim:
Code:
ssh -T git@gitlab.com
Do NOT replace anything. I just created a dummy account in gitlab, pasted my SSH key and after clicking "Add Key" everything worked. You could try, just to be sure:
Code:
ssh -i "$HOME/.ssh/id_rsa" -T git@gitlab.com
If you named your key anything else then "id_rsa" then use that name instead.
i did not change anything except my username where it was required. i copied and pasted commands as is
Host gitlab.com
User apoorv569
PubKeyAuthentication yes
IdentityFile /home/apoorv/.ssh/id_rsa.pub
its still giving that error
You do not need the *.pub extension:
Code:
Host gitlab.com
User apoorv569
PubKeyAuthentication yes
IdentityFile /home/apoorv/.ssh/id_rsa
should be enough.
Go to the SSH page of your account and make sure that you pasted the key correctly. It should display an MD5SUM and an SHA256SUM. You MUST paste the entire content of the key, i.e., the pasted key should look like
Host gitlab.com
User apoorv569
PubKeyAuthentication yes
IdentityFile /home/apoorv/.ssh/id_rsa
should be enough.
Go to the SSH page of your account and make sure that you pasted the key correctly. It should display an MD5SUM and an SHA256SUM. You MUST paste the entire content of the key, i.e., the pasted key should look like
Code:
ssh-rsa ... == email@example.com
or whatever you entered as email.
yes i pasted full key including email also. it displayed MD5 and SHA256 also. i also tried this on my desktop pc. still giving same error. the id_rsa file private key and .pub is public key on the gitlab page it says paste the .pub file. could it be a firewall issue? i do have an firewall but i have port 22 open
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.