👋 We've unified all of GitHub's product documentation in one place! Check out the content for REST API, GraphQL API, and Developers. Learn more on the GitHub blog.
Article version: Enterprise Server 2.21

Git automation with OAuth tokens

You can use OAuth tokens to interact with GitHub Enterprise via automated scripts.

In this article

Were you able to find what you were looking for?

Step 1: Get an OAuth token

Create a personal access token on your application settings page. For more information, see "Creating a personal access token."

Tip: We recommend that you regularly review your authorized integrations. Remove any applications and tokens that haven't been used in a while. For more information, see "Reviewing your authorized integrations."

Step 2: Clone a repository

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:

$ git clone https://hostname/username/repo.git
Username: your_username
Password: your_token

To avoid these prompts, you can use Git password caching. For information, see "Caching your GitHub credentials in Git."

Warning: Tokens have read/write access and should be treated like passwords. If you enter your token into the clone URL when cloning or adding a remote, Git writes it to your .git/config file in plain text, which is a security risk.

Further reading

Were you able to find what you were looking for?

Ask a human

Can't find what you're looking for?

Contact us