How to git push with token
How to git push with token
How to use a new token to push to github?
In order to push something to github it looks like I need to create a new token (again. ). But what that new token, how do I tell git to use a new token? What command do I have to use to use the new token?
2 Answers 2
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
It seems that git does not provide a ‘nice’ way to update your token. But here is how you can do it:
You remove the old origin
You add the new origin with the token integrated, i.e.
so it looks like e.g.
Hint:
Sometimes this procedure will not work.
From the GitHub doc :
Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.
so just make sure that the old token is no longer cached in your laptop and use the token generated as a password
you can find in the link how to create a new token
Not the answer you’re looking for? Browse other questions tagged git github or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Pushing to remote Git repository from a build
Sometimes during the build (say, on successful build) you need to make a commit to Git repo and push it back to your remote repository. This could be a new tag as well which could be used to kick off deployment or mark a release.
Running something on successful builds is not a problem. Just add to your appveyor.yml :
Note: AppVeyor checks out only the last commit and not the entire branch. So you may have to check out the wanted branch: git checkout master
But the main question here is how to authenticate Git commands. If you try using any Git command against remote repository you’ll get stuck build because Git is asking for credentials. In most cases you can’t supply username/password in command line (we are not considering the case when credentials are embedded in repo URL as this is bad).
Two methods to access remote Git repository exist: SSH and credentials store. The scenario with custom SSH key is described in this article (with the only difference is that the key should be deployed under GitHub user account, not repo, to have write access).
This article will demonstrate how to use Git credential store to avoid Git asking for credentials and stalling the build. We will be using GitHub as a repository provider, however described technique could be applied to any Git hosting.
Creating GitHub Personal Access Token
The scope needed is public_repo for a public repository or repo for a private repository.
Configuring build secure variable with access token
Enabling Git credential store
Git doesn’t preserve entered credentials between calls. However, it provides a mechanism for caching credentials called Credential Store. To enable credential store we use the following command:
Adding access token to credential store
Default credential store keeps passwords in clear text (this is OK for us as build worker is private and not re-used or shared between builds). The storage represents a single %USERPROFILE%\.git-credentials file where each line has a form of:
For example, for GitHub access token it will be:
When authenticating with access token x-oauth-basic is used as a stub password.
Note: $HOME is an automatic variable available in powershell on Windows and Linux and is therefore cross-platform. If you currently use cmd: you can use %USERPROFILE% instead.
Indicate git user name and mail
You have to indicate your git user name and mail:
Updating remote
If you are pushing to the same private repository the build was cloned from you should probably update its remote or add a new one using HTTPS protocol.
how to use Personal access token to clone, pull, and push a repo? [duplicate]
Today GitHub surprise me with a new way to push, clone, or pull a repo
when I’m trying to push my project I get this error message:
after multiple searches I fined that GitHub adds a new security update named Personal access tokens but who can I use it?
2 Answers 2
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
You have to use SSH keys. Create one for each computer and register them all to the repo that you need to access. Doing this allows you to remove access computer by computer.
Once you have the SSH keys configured in Github, you can read this article to setup the Personal Access Tokens.
UPDATE It tells you how to change to the token in the documentation
Using a token on the command line
Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.
For example, on the command line you would enter the following:
Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS.
If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token.
Instead of manually entering your PAT for every HTTPS Git operation, you can cache your PAT with a Git client. Git will temporarily store your credentials in memory until an expiry interval has passed. You can also store the token in a plain text file that Git can read before every request. For more information, see «Caching your GitHub credentials in Git.»
Also found a good video walkthrough that may help clear up a few things.
git push using GitHub token [Deprecating password authentication]
I am using git for version control and GitHub for the repository of my code development. Every git push of my work to the repository is prompted to input my GitHub username and password. I would like to avoid it for every push, but how to setup git push to use GitHub token.
Solution:
Password-based authentication for Git is deprecated and you should make the push based on the token authentication. GitHub has personal access token (PAT), to use in place of a password with the command line or with the API. Below is how to generate the token and use it:
Create a token in GitHub
2. Click on Developer Settings
3. Click on Personal Access Tokens
4. Click on Generate new token
5. Now type in the name of the token and select the scopes, or permissions, you’d like to grant this token. Make sure you select repo to use your token to access repositories from the command line. Click Generate token.
Make sure to copy your personal access token immediately. You won’t be able to see it again!
How to git push using GitHub token on the command line
Personal Access Tokens (PAT) can only be used for HTTPS git operations. Switch your repository to HTTPS if it is using SSH.
Once you have a token, you can use it instead of your password when performing git push operations over HTTPS as below:
How to do git commit using personal access token?
I made all permission reserved personal access token on github.
So How can I clone, commit, and push using personal access tokens?
4 Answers 4
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Login to your GitHub and go and setup a «Personal Access Token» at https://github.com/settings/tokens
After you have your personal access token, go to terminal and change your «origin» url as below
If it is your first time starting your repo and haven’t pushed before, then add your initial origin as below
While it is possible to use the personal access token in the URL like that, it’s discouraged because (a) it stores your token in plaintext where it can be read and printed and (b) because it means you have to enter it for each repository.
It’s better to use a credential manager to store your credentials by setting credential.helper to an appropriate value for your platform, and then entering your username when prompted and your token as the password. That will save your credentials for future use across all your projects. If you need to use multiple accounts, just use your username (but not your token) in the URL, and the credential manager will handle that.
The default credential managers you want to use on most platforms are manager or wincred on Windows, osxkeychain on macOS, and libsecret on Linux. You can also use store to store in a file on your local disk, which is available on all platforms, but less secure.
Источники информации:
- http://www.appveyor.com/docs/how-to/git-push/
- http://stackoverflow.com/questions/68199793/how-to-use-personal-access-token-to-clone-pull-and-push-a-repo
- http://techglimpse.com/git-push-github-token-based-passwordless/
- http://stackoverflow.com/questions/62177166/how-to-do-git-commit-using-personal-access-token