<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Daniel Akudbilla</title>
    <description>The latest articles on Forem by Daniel Akudbilla (@daniel_akudbilla_999ccff6).</description>
    <link>https://forem.com/daniel_akudbilla_999ccff6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2909057%2F3d781239-62a1-4645-8613-7b48547ed190.jpg</url>
      <title>Forem: Daniel Akudbilla</title>
      <link>https://forem.com/daniel_akudbilla_999ccff6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/daniel_akudbilla_999ccff6"/>
    <language>en</language>
    <item>
      <title>How to Push to a Private GitHub Repository Using a Fine-Grained Personal Access Token</title>
      <dc:creator>Daniel Akudbilla</dc:creator>
      <pubDate>Sat, 29 Mar 2025 12:39:25 +0000</pubDate>
      <link>https://forem.com/daniel_akudbilla_999ccff6/how-to-push-to-a-private-github-repository-using-a-fine-grained-personal-access-token-39ll</link>
      <guid>https://forem.com/daniel_akudbilla_999ccff6/how-to-push-to-a-private-github-repository-using-a-fine-grained-personal-access-token-39ll</guid>
      <description>&lt;p&gt;If you have an existing local Git repository and need to push it to a &lt;strong&gt;private GitHub repository&lt;/strong&gt;, but GitHub is rejecting your credentials, you may need to use a &lt;strong&gt;fine-grained personal access token (PAT)&lt;/strong&gt;. This guide will walk you through the process step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Generate a Fine-Grained Personal Access Token (PAT)
&lt;/h2&gt;

&lt;p&gt;GitHub has moved away from password authentication for Git operations, so you must use a personal access token (PAT) instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1.1 Navigate to GitHub Settings&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://github.com/settings/tokens" rel="noopener noreferrer"&gt;GitHub Personal Access Tokens&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;"Generate new token (fine-grained)"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1.2 Configure Token Permissions&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Repository Access:&lt;/strong&gt; Select the specific repository you want to push to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Under "Repository permissions," set &lt;strong&gt;"Read and Write"&lt;/strong&gt; access for "Contents."&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Expiration:&lt;/strong&gt; Choose an expiration date or select "No expiration" (not recommended for security reasons).&lt;/li&gt;

&lt;li&gt;Click &lt;strong&gt;"Generate token"&lt;/strong&gt; and &lt;strong&gt;copy&lt;/strong&gt; the token immediately (you won’t see it again).&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Set the Remote URL with the PAT
&lt;/h2&gt;

&lt;p&gt;Now, update your Git remote URL to authenticate using the token.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.1 Navigate to Your Local Repository&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Open a terminal and move to your project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /path/to/your/local/repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2.2 Update the Remote URL&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Run the following command, replacing &lt;code&gt;{your-personal-token}&lt;/code&gt;, &lt;code&gt;{github_username}&lt;/code&gt;, and &lt;code&gt;{private-repo-name}&lt;/code&gt; accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote set-url origin https://&lt;span class="o"&gt;{&lt;/span&gt;your-personal-token&lt;span class="o"&gt;}&lt;/span&gt;@github.com/&lt;span class="o"&gt;{&lt;/span&gt;github_username&lt;span class="o"&gt;}&lt;/span&gt;/&lt;span class="o"&gt;{&lt;/span&gt;private-repo-name&lt;span class="o"&gt;}&lt;/span&gt;.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The token will be stored in your Git configuration. For security reasons, it’s best to use a Git credential manager instead of embedding it in the URL.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 3: Push Your Code to GitHub
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3.1 Add and Commit Changes&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you haven’t already committed your changes, do so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3.2 Push to the Private Repository&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now, push your code to GitHub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is set up correctly, your repository should now be updated on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Verify Your Push
&lt;/h2&gt;

&lt;p&gt;Go to your GitHub repository and refresh the page. You should see your files successfully pushed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: Use a Credential Manager for Better Security
&lt;/h2&gt;

&lt;p&gt;Instead of storing your token in the remote URL, you can configure a credential manager to securely store and automatically use your token when needed.&lt;/p&gt;

&lt;p&gt;For macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git credential-osxkeychain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git credential-manager-core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git credential-store
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, configure Git to use the credential manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; credential.helper store
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, you won’t need to include your token in the remote URL manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By following these steps, you should be able to push to a private GitHub repository using a fine-grained personal access token. This method ensures secure authentication without exposing your GitHub password. Always remember to keep your access tokens safe and use GitHub's credential storage features for added security.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Cloning a Private GitHub Repository Using HTTPS</title>
      <dc:creator>Daniel Akudbilla</dc:creator>
      <pubDate>Mon, 03 Mar 2025 20:52:56 +0000</pubDate>
      <link>https://forem.com/daniel_akudbilla_999ccff6/cloning-a-private-github-repository-using-https-3p4k</link>
      <guid>https://forem.com/daniel_akudbilla_999ccff6/cloning-a-private-github-repository-using-https-3p4k</guid>
      <description>&lt;p&gt;If you're here, you're either struggling to clone a private GitHub repository or simply trying to learn how. Let's dive straight into the solution.&lt;br&gt;
You have encountered this error&lt;br&gt;
&lt;code&gt;Cloning into 'repo_name'...&lt;br&gt;
remote: Write access to repository not granted.&lt;br&gt;
fatal: unable to access 'https://github.com/username/repo_name.git/': The requested URL returned error: 403&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1: Generate a Personal Access Token (PAT)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To clone a private repository using HTTPS, you need a &lt;strong&gt;Personal Access Token (PAT)&lt;/strong&gt; instead of a password. Follow these steps to generate one:&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. Log in to GitHub&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and sign in to your account.&lt;/li&gt;
&lt;li&gt;Click on your profile picture in the top-right corner.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;2. Navigate to Developer Settings&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Scroll down and click on &lt;strong&gt;Developer settings&lt;/strong&gt; (found in the left sidebar).&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Personal access tokens&lt;/strong&gt;, select &lt;strong&gt;Fine-grained tokens&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Generate new token&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmrf7yqlcktj3jffgml3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmrf7yqlcktj3jffgml3u.png" alt="access token image" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;3. Configure the Token&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name the token&lt;/strong&gt; (e.g., &lt;em&gt;GitHub Repo Access&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Select the resource owner:&lt;/strong&gt; Choose your GitHub username (or your organization if cloning an organization repo).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set an expiration date:&lt;/strong&gt; Choose an appropriate duration for security purposes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repository access:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Select &lt;strong&gt;All repositories&lt;/strong&gt; (if you want access to all your repos).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommended:&lt;/strong&gt; Select only the specific repositories you need access to.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Under &lt;strong&gt;Repository permissions&lt;/strong&gt;, find &lt;strong&gt;Contents&lt;/strong&gt; and set it to &lt;strong&gt;Read and Write&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Find &lt;strong&gt;Administration&lt;/strong&gt; and set it to &lt;strong&gt;Read and Write&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Grant additional permissions as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdd5rnoqiixwdqxj2wsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdd5rnoqiixwdqxj2wsg.png" alt="Permissions options to be selected" width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;4. Generate and Copy the Token&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click &lt;strong&gt;Generate Token&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Important:&lt;/strong&gt; Copy the generated token and store it securely, as it will not be shown again.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Clone the Private Repository&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;With your &lt;strong&gt;Personal Access Token (PAT)&lt;/strong&gt; ready, follow these steps to clone your private repository:&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. Open Your Terminal&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;On &lt;strong&gt;Windows&lt;/strong&gt;, use &lt;strong&gt;Git Bash&lt;/strong&gt; or Command Prompt.&lt;br&gt;
On &lt;strong&gt;Mac/Linux&lt;/strong&gt;, use the Terminal.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;2. Run the Clone Command&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use the following command to clone your repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://USERNAME:TOKEN@github.com/USERNAME/REPOSITORY_NAME.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Replace:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;USERNAME&lt;/code&gt; → Your GitHub username&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TOKEN&lt;/code&gt; → Your generated Personal Access Token&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;REPOSITORY_NAME&lt;/code&gt; → The name of your repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://johnDoe:ghp_ABC123xyz@github.com/johnDoe/my-private-repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is correct, your repository should start cloning successfully.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I personally struggled with this issue for a while and decided to share my findings after thorough research. I hope this guide helps you avoid the same frustration. If you found this useful, share it with others who might need it!&lt;/p&gt;

&lt;p&gt;🚀 &lt;strong&gt;Happy coding!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>git</category>
    </item>
  </channel>
</rss>
