My setup is Visual Studio Code on windows 10. I have installed Git for windows and would like to use Google Cloud Repositories in Visual Studio Code.
I have set up the credential helper to be gcloud.md. I made sure the correct project/id is selected in gcloud.
When I push the changes to Google repository i get the message
fatal: remote error: Access denied to zzz#zzz.com
The message is correct the user does not have access. But the user is not the active user in gcloud. But I would expect the active user in gcloud to be used for the authentication.
How can I use gcloud as the credentials helper and authenticate with the different available gcloud users?
When you use gcloud source repos clone gcloud is added as a credential helper for that repository. It is configured to always use the gcloud account that was active when you cloned the repo (since that is the account that would have access and that presumably you would want to use from that point on). So regardless of your current gcloud settings, opertaions on that repo will continue to use that account.
You can see this if you run:
git config credential.helper
from within that repo. It will print the gcloud command that runs, and it should have a --account flag pointing to a specific account.
If you want to change the account, you can change your gcloud account and clone the repo again, or you can use git config to edit that credential helper setting and put whatever account you intended.
Related
I use the git integration with VSCode and got the notification today that I need to renew my access token. I did so and have my new token (which I obtained through the web interface). Now I need to set my local git configuration to use the new token instead of the old one which will expire in a few days.
The VSCode docs suggest the following:
To execute the 'GitHub: Set Personal Access Token' type Ctrl+Shift+p in VSCode to open the command palette and type 'GitHub: Set Personal Access Token'. You will then be prompted to enter the token generated from GitHub.
This option isn't available in my git integration in VS code (maybe I need an update?)
How can I do this from the command line?
If you want to update Github Personal Access Token in VSCode, you need to install Github Extension
You can also update Github Personal Access Token via command line
Open a command line and set the current directory to your project root
Run the command to set remote access via a token
git remote set-url origin https://username:token#github.com/username/repository.git
Example:
git remote set-url origin https://exampleuser:b8c28127***63gu56b2d#github.com/exampleuser/exampleproject.git
Not sure if you are running on windows, but modern git binaries are using windows credential manager to store the GitHub / Git authentication details. To modify them, go to the windows "credential manager". The procedure is detailed here: https://www.sqlservercentral.com/blogs/changing-git-credentials-in-windows
I am part of an organization that uses SSO in Github. I don't have problem to access the repository through the web, it redirects me to SSO login and that's all.
The problem started when I logged-in first to my personal repository on GitHub through Git-Bash, I did some changes and then I wanted to do changes in a repository from my organization. When I run the below command, it wrote me that I need to re-authorize the OAuth Application, but I don't understand how:
$ git push --delete origin v0.1.3
remote: The `<my_company>' organization has enabled or enforced SAML SSO. To access
remote: this repository, you must re-authorize the OAuth Application `Git Credential Manager`.
fatal: unable to access 'https://github.com/<my_company>/myproj.git/': The requested URL returned error: 403
How can I re-authorize the login?
I tried to re-open Git-Bash but it wrote me the same error.
My company just enabled SSO for my Github Org overnight so was getting the same error running git pull. I fixed this with the following steps.
Open Credential Manager in Windows and delete the existing credential for github.com
Re-initialise the cred manager in git bash: git config --global credential.helper manager-core
Re-run git pull and follow the pop-up instructions to authenticate in a browser (which happened automatically for me with SSO).
After those steps git commands worked for me again.
I used the Github cli by running the following in the terminal
gh auth login
which then prompted me to re-authenticate, and I was able to.
If you do not have the CLI (Command Line Interface) currently installed, you can visit https://cli.github.com/ for more information. There is a download for Mac.
For VSCode users or any other IDE you need to re-authorize the app!
Go to your settings on GitHub -> Applications -> Authorized OAuth Apps,
Search for "GitHub for VSCode", and choose "Revoke" from the "..." menu.
If you then sign out in VSCode and sign in again, you should be prompted to re-authorized
Delete git from "credential manager" window's application. Then pull on repo again. The sso authentication should automatically come up.
This works for me by revoking the current application in the Github Settings > Settings > Applications > Authorized OAuth Apps
and then try the git pull again.
I set up my SSH key for my account.
When I run git clone in my terminal I usually get Forbidden fatal: could not read from remote repository.
Running ssh-add -l shows the correct authenticated agent.
Running git clone is now asking for my passphrase with the above error message.
Saying "please make sure you have the correct access rights and the repository exists."
I ran ps to make sure there was only one authenticated agent
The clone command is git clone git#bitbucket.org:<filepath>.git
The URL should:
not be git#bitbucket.org:<filepath>.git
but git#bitbucket.org:<account>/<projectname>.git
you can use:
export GIT_SSH_COMMAND='ssh -Tv'
You will see which key SSH is using.
Make sure the public key has been registered to your Bitbucket account settings.
But the OP adds:
It's private and I'm not the owner. Does something need to be updated with access settings by the owner?
Then yes, your account needs to be granted access in that repository by its owner.
I am trouble to push code onto gcloud with
git push google master. It always says.
ERROR: (gcloud.auth.git-helper) unrecognized arguments: --ignore-unknown
I already checked gcloud.cmd is in path and gcloud auth list shows my username on gcloud. Not sure where is --ignore-unknown coming from.
Tom
gcloud uses a hidden command,
gcloud auth git-helper
as a git credential helper[1] to authenticate for git push/pull operations. The error message you're seeing is probably a sign that the gcloud auth component of gcloud is out of date. Your best bet is to run
gcloud components update
to make sure all glcoud components are up to date.
[1] If you're curious about git credential helpers you might start here: https://www.kernel.org/pub/software/scm/git/docs/v1.7.9/gitcredentials.html.
I am trying to gain access to the embedded git repository for an existing Google Developers Console (GDC) project. The GDC shows the git repository under -SOURCE CODE-Releases. I followed the official gcloud installation instructions to the point:
gcloud auth login /* pulls up browser and does authentication just fine */
gcloud config set project <project>
gcloud init <project>
The latter always results in the following (replacing actual project name with 'fishbone'):
$gcloud init fishbone
Initialized gcloud directory in [/Users/dummy/Workspace/fishbone/.gcloud].
Cloning [https://source.developers.google.com/p/fishbone/r/default] into [default].
Initialized empty Git repository in /Users/dummy/Workspace/fishbone/default/.git/
fatal: remote error: Invalid username/password.
You may need to use your OAuth token password; Note that generated google.com passwords are not compatible with private repositories
ERROR: Unable to initialize project [fishbone], cleaning up [/Users/dummy/Workspace/fishbone].
ERROR: (gcloud.init) Could not fetch repository.
Only on the very first installation of the SDK (re-tried more than once now), I remember gcloud init asking for a username. Never again after this. Mac OS X 10.9.3 and:
$git --version
$git version 1.8.5.2 (Apple Git-48)
I am aware of this related gcloud init issue, but it's not this. Help greatly appreciated.
Go to https://console.developers.google.com/project/your-project-id > Source Code > Browse > Find this line : "Alternatively, instead of using the Google Cloud SDK to manage your authentication, you can manually generate your Git credentials by following this link." > Click "following this link" and you can see your git password. As you can see in your error, google password are not compatible with private repositories. Now you can :
Use your gmail and git password above to clone reposite.
Or create .netrc file at your home folder and add : "machine source.developers.google.com login your-email#gmail.com password 1/abxxxxxxxxxxxxxxxxxxxxxxx" to this file. It will not request your password again.
Just goto your Google Developer Console and click /
find the content like below
"Alternatively, instead of using the Google Cloud SDK to manage your authentication, you can manually generate your Git credentials by following this link."
and click "following this link" then follow the instructions on that page.
Thats all.
They moved the options to manually created Git credentials. The options are now under GCP -> (tools) Development -> Source Code
and under the options when cloning new or existing repos they give you the option to use gcloud or create your own credentials.
also below in screenshots