Git pull in GitHub as collaborator - github

I'm the admin in a GitHub repository and I've added a collaborator, this collaborator needs to pull the repository and the system asks the access token.
How can a collaborator download a GitHub repository and how I create an access token for them?

I've found the solution, basically the collaborator needs to create an access token and then clone the repository, when prompted for Username, fill the username and when prompted for password you need to put the access token (not the password).

You do not need to provide them an access token. Assuming your repository is private, the collaborator needs to authenticate to GitHub when pulling (and when pushing even if the repository is public). The should do that by setting up their own account appropriately.
That can be by using their own personal access token as the password when prompted for the username and password over HTTPS, which they can create in the settings page, or they can create an SSH key and upload the public part to GitHub, and then use SSH to clone from or push to the repository.

The collaborater can clone the repo to their terminal using their own personal access token.

Related

remote: Write access to repository not granted. - admin of repo but within an organisation

I'm part of an organization, and through the UI I can create a private repository inside that organization.
Going on repository -> setting -> Collaboration and team, I can see
I'm the admin
I've created my PAT and in fact, I can commit and push other
public repositories.
But if I clone this new repository I get "fatal: unable to access"
Is there anything specific to do when creating repos inside an organization?
If I try to create a new PAT and try to create it for specific repos, I can't see this new repo in the list of my repos! So I have to create it for "All repositories".
Other trials:
git clone https://<username>:<token>#github.com/orgName/repoName failed
git clone https://<username>#github.com/orgName/repoName failed
git clone https://github.com/orgName/repoName of course failed as well
BUT, one strange thing:
git clone https://<token>#github.com/orgName/repoName asked me for a password
I didn't go on, maybe it's recognized just as a new username so it was asking for a password
Turns out for whatever reason you have to use ssh and cannot use PAT and https. After registering a key on GitHub everything worked as expected.
Here is the guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys
If it is a private repository that is accessed using the classic Personal Access Token(PAT) try resetting the fetch and push url for the remote repo by running:
git remote set-url origin https://<classic PAT >#github.com/organization_name/repo_name
In order to do the same while using the newer fine-grained token:
git remote set-url origin https://oauth2:<fine-grained PAT >#github.com/organization_name/repo_name
If indeed the Personal access token above is authorized to access that repo you should now be able to do all functions from before such as cloning, pushing and pulling.

Gitlab: tokenless push to github repo?

I've set up an account on github. I've uploaded my ssh public key.
On github I've created a new empty repo.
In my local environment I've set up git to manage a project. Now I'd like to push the project to github.
When I do 'git push -u origin main', I am asked for my username and password.
The first time I did this I received a message that directed me to the use of tokens. So I created a token. However, now I have to input my token ever time I push to github.
Up until recently I was able to push without entering a password/token thanks to the use of ssh keys. Is it possible to still use this?
If so, how do I get it working?
You can configure username and password by default and it wont ask you again and again, but make sure the username has access to that repository.

How to solve an error while cloning a private repository

I have a repository which is private. Before, I was able to clone it from my terminal by giving the username and password. Few days back I got a mail from GitHub to enable 2FA in my account. I did but now I see my account password doesn't seem to work when I give my password in my terminal. I use Google Authenticator as my TOTP app and I also tried giving that password but still it says authentication failure. Please help me out
You need a "Personal Access Token" (PAT).
In order to generate one, go to your GitHub settings and click on the category called "Developer settings". In that section, go to personal tokens.
There you can generate a new access token (make surer to check repo). When you clone your repository, use this token instead of your password. Now you should be able to clone it.
You can read more about this process here: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token

Trying to import GitLab repository to Azure repository but I am getting the below error

Import request cannot be processed due to one of the following reasons:
Clone URL is incorrect.
Clone URL requires authorization.
NOTE: I am getting this error even though I am providing the correct username and password. And I am able to clone the repository locally with the same clone url.
If you are using credentials (username/password) to clone the repository, that should mean its URL is an HTTPS one.
This answer suggests an issue with an empty repository or a wrong PAT.
The last suggestions reminds me you should try and use a token as your password, instead of your GitLab account password. See if you can create a PAT (Personal Access Token), and use that as a password.

Configure Jenkins For Github CI w/ 2FA

My Github account has two factor authorization (2fa) enabled. I want to integrate Jenkins with a few of my private repositories, but I cannot authorize them because I have 2fa enabled. Note this is a multibranch pipeline project.
Any ideas how to configure Jenkins to connect with private repos without creating a dummy account that does not have 2fa enabled?
Whoever would have thought to click the help button?
Credentials used to scan branches and pull requests, check out sources and mark commit statuses.
If none is given, only the public repositories will be scanned, and commit status will not be set on GitHub.
If your organization contains private repositories, then you need to specify a credential from an user who have access to those repositories.
This is done by creating a "username with password" credential where the password is GitHub personal access tokens. The necessary scope is "repo"
ie use a Github personal access token as your password when using username/password for your Jenkins credential.