{"id":2506,"date":"2023-02-24T15:49:04","date_gmt":"2023-02-24T15:49:04","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=2506"},"modified":"2023-02-24T15:49:06","modified_gmt":"2023-02-24T15:49:06","slug":"pat-personal-access-token","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2023\/02\/24\/pat-personal-access-token\/","title":{"rendered":"PAT: Personal Access Token"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"245\" height=\"129\" src=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2023\/02\/an-lint.png\" alt=\"\" class=\"wp-image-2507\"\/><\/figure>\n<\/div>\n\n\n<p>Using Git Personal Access Tokens (PATs) is a secure and convenient way to authenticate with Git service providers. In this blog post, we will discuss how to use Git PATs on both Mac and CentOS 7 systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generation a PAT<\/h2>\n\n\n\n<figure class=\"wp-block-pullquote has-medium-font-size\" style=\"border-width:3px;border-radius:39px;font-style:normal;font-weight:400\"><blockquote><p>You can refer to the previous <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.samarthya.me\/wps\/2021\/09\/23\/personal-access-token\/\" target=\"_blank\">blog<\/a><\/p><\/blockquote><\/figure>\n\n\n\n<p>Before we begin, we need to generate a Personal Access Token from our Git service provider. The exact steps to generate a PAT may differ depending on the service provider, but usually, you can find the option to generate a PAT under your account settings.<\/p>\n\n\n\n<p>Once you have generated your PAT, keep it safe as it will be used to authenticate with Git service providers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using on OSX<\/h2>\n\n\n\n<p>To configure Git to use a PAT on a Mac, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open Terminal on your Mac.<\/li>\n\n\n\n<li>Set your Git username and email address using the following commands:\n<ul class=\"wp-block-list\">\n<li><code>git config --global user.name \"Your Name\" <\/code><\/li>\n\n\n\n<li><code>git config --global user.email \"youremail@example.com\"<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Configure Git to use the PAT for authentication by running the following command:\n<ul class=\"wp-block-list\">\n<li><code>git config --global credential.helper osxkeychain<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>When you run any Git command that requires authentication, Git will prompt you for your username and PAT. Enter your Git username and PAT and select the &#8220;Always allow&#8221; option to store the credentials in the macOS Keychain.<\/li>\n<\/ol>\n\n\n\n<p>Now, Git will automatically use the stored credentials when you run any Git command that requires authentication.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Git PAT on CentOS 7<\/h3>\n\n\n\n<p>To configure Git to use a PAT on CentOS 7, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the terminal on your CentOS 7 machine.<\/li>\n\n\n\n<li>Set your Git username and email address using the following commands:\n<ul class=\"wp-block-list\">\n<li><code>git config --global user.name \"Your Name\" <\/code><\/li>\n\n\n\n<li><code>git config --global user.email \"youremail@example.com\"<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Configure Git to use the PAT for authentication by running the following command:\n<ul class=\"wp-block-list\">\n<li><code>git config --global credential.helper store<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create a new file named <code>.git-credentials<\/code> in your home directory using the following command:\n<ul class=\"wp-block-list\">\n<li> <code>touch ~\/.git-credentials<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Open the <code>.git-credentials<\/code> file using a text editor and add the following lines:\n<ul class=\"wp-block-list\">\n<li> <code>https:\/\/&lt;git-service-provider>\/username:personal-access-token<\/code><\/li>\n\n\n\n<li>Replace <code>&lt;git-service-provider&gt;<\/code> with the URL of your Git service provider (e.g. github.com, gitlab.com, bitbucket.org, etc.).<\/li>\n\n\n\n<li>Replace <code>username<\/code> with your Git username.<\/li>\n\n\n\n<li>Replace <code>personal-access-token<\/code> with the PAT that you generated earlier.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Save and close the <code>.git-credentials<\/code> file.<\/li>\n<\/ol>\n\n\n\n<p>Now, when you run any Git command that requires authentication, Git will automatically use the PAT that you specified in the <code>.git-credentials<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>In this blog post, we discussed how to use Git Personal Access Tokens (PATs) on both Mac and CentOS 7 systems. By configuring Git to use PATs, we can authenticate securely with Git service providers and avoid the need to enter our username and password every time we use Git.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Git Personal Access Tokens (PATs) is a secure and convenient way to authenticate with Git service providers. In this blog post, we will discuss how to use Git PATs on both Mac and CentOS 7 systems. Generation a PAT You can refer to the previous blog Before we begin, we need to generate a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[289,193,288],"class_list":["post-2506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical","tag-configure","tag-pat","tag-tokens"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=2506"}],"version-history":[{"count":1,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2506\/revisions"}],"predecessor-version":[{"id":2508,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2506\/revisions\/2508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/2507"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=2506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=2506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=2506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}