How can we connect to a git account from Google cloud shell which already has git installed?

Issue

I am able to see git already installed in cloud shell. Also, when i fire
‘git config –list’ command i get below output.

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
credential.https://source.developers.google.com.helper=gcloud.sh
core.repositoryformatversion=0
core.filemode=true
core.bare=false

Which credentials are these? And how can I connect to my github account?

Thanks in advance.

Solution

Thank you everyone for your answers. I’ll mention what worked for me.

I set up git configuration using

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

when I cloned my private repo using,

git clone https://[your-git-repo].git

I had to enter my GitHub password. Then I performed whatever changes I had to make and after commiting did

git push

Again I had to provide my github password and the changes were pushed to my private repo.
Please let me know if there is any better/ideal way to achieve the same.

edit:
Password Authentication has been removed from Aug2021 onwards. So now, this solution won’t work.
One of the alternatives to authenticate to GIT account is by generating Personal Access Token. Details can be found here

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic

Once token is generated, save the token and it can be used instead of password to authenticate to Github.

Answered By – bilalgazge

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published