LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 06-20-2020, 01:01 PM   #1
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Rep: Reputation: 0
Question Git - how to choose which account to commit to?


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?
 
Old 06-20-2020, 01:59 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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.

PS:
You can also take a look on the official git documentation for working with remotes.

Last edited by crts; 06-20-2020 at 02:01 PM.
 
Old 06-20-2020, 03:12 PM   #3
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
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.

PS:
You can also take a look on the official git documentation for working with remotes.
it is not an existing repository, actually i want to store my dotfiles and custom DWM build. what are differences between using SSH or HTTPS?

so you mean i have to use remote repository for i want to achieve?

the gitlab site says i need to
Code:
git remote add <source-name> <repository-path>
what should i put on <source-name> field?

Last edited by apoorv569; 06-20-2020 at 03:21 PM.
 
Old 06-20-2020, 03:22 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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.

Last edited by crts; 06-20-2020 at 03:28 PM.
 
Old 06-20-2020, 03:35 PM   #5
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by apoorv569 View Post
the gitlab site says i need to
Code:
git remote add <source-name> <repository-path>
what should i put on <source-name> field?
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.
 
Old 06-20-2020, 04:23 PM   #6
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
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.
 
Old 06-20-2020, 05:07 PM   #7
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by apoorv569 View Post
... 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:
Code:
$ cat $HOME/.ssh/config
Host gitlab.com
User <gitlab-username>
PubKeyAuthentication yes
IdentityFile /home/<local-username>/.ssh/<name-of-key>
Notice, that you cannot use the $HOME variable inside the configuration file.
 
Old 06-20-2020, 05:28 PM   #8
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by crts View Post
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:
Code:
$ cat $HOME/.ssh/config
Host gitlab.com
User <gitlab-username>
PubKeyAuthentication yes
IdentityFile /home/<local-username>/.ssh/<name-of-key>
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

Last edited by apoorv569; 06-20-2020 at 05:35 PM.
 
Old 06-20-2020, 06:00 PM   #9
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
Code:
$ cat $HOME/.ssh/config
Host gitlab.com
User <gitlab-username>
PubKeyAuthentication yes
IdentityFile /home/<local-username>/.ssh/<name-of-key>
i created this file in "~/.ssh/config"
Code:
   Host gitlab.com
   User apoorv569
   PubKeyAuthentication yes
   IdentityFile /home/apoorv/.ssh/id_rsa.pub
its still giving that error
 
Old 06-20-2020, 06:02 PM   #10
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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.
 
Old 06-20-2020, 06:06 PM   #11
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
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
 
Old 06-20-2020, 06:11 PM   #12
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by apoorv569 View Post
i created this file in "~/.ssh/config"
Code:
   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
Code:
ssh-rsa ... == email@example.com
or whatever you entered as email.
 
Old 06-20-2020, 06:17 PM   #13
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by apoorv569 View Post
i did not change anything except my username where it was required.
Where was it required?
 
Old 06-20-2020, 06:17 PM   #14
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
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
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

Last edited by apoorv569; 06-20-2020 at 06:20 PM.
 
Old 06-20-2020, 06:22 PM   #15
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by crts View Post
Where was it required?
during the whole process i mean and in the config file you told me to make
 
  


Reply

Tags
git, gitlab, linux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Gitpod git-bolts git-IDE onto GitHub for in-browser code git-editing LXer Syndicated Linux News 0 09-05-2018 04:50 AM
[SOLVED] cvs [commit aborted]: 'root' is not allowed to commit files Joaquin Linux - Software 5 11-28-2013 05:48 AM
cvs [commit aborted]: 'root' is not allowed to commit files rakesh@linuxforum Linux - Newbie 7 09-26-2013 03:53 PM
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 02:09 PM
cvs [commit aborted]: 'root' is not allowed to commit files r_ramya06 Linux - Newbie 5 07-08-2008 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration