My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label github. Show all posts
Showing posts with label github. Show all posts

Tuesday, March 10, 2026

How to set new Github PTA when old expired

I ran into a situation. My Personal Access Token on Git expired and I wanted to generate and set in my git terminal locally. The problem was that my git was still taking old PTA from command line. I kept on asking for old PTA which was now expired. Let me walk you through what was done next.

But first - Let's learn to set a new Personal Access Token (PAT) on your Mac, you need to first generate it on the GitHub website and then enter it into your terminal when prompted.

Step 1: Generate a New PAT on GitHub

  1. Log into GitHub.com and go to your Settings (click your profile photo in the top right).
  2. On the left sidebar, scroll to the bottom and click Developer settings.
  3. Click Personal access tokens -> Tokens (classic).
  4. Click Generate new token (classic).
  5. Note: Give it a name (e.g., "MacBook Pro").
  6. Expiration: Choose a duration (or "No expiration" if you prefer).
  7. Scopes: Select the repo checkbox (this is required for push/pull access).
  8. Click Generate token and copy the token immediately. You will not be able to see it again.

To update your Personal Access Token (PAT) because Git is still using an old, expired one, you must clear the existing credentials from your system's storage so Git can prompt you for the new one.
1. Clear Old Credentials (Required)
Choose the steps for your specific Operating System:
  • Windows:
    1. Open the Start Menu, search for "Credential Manager", and open it.
    2. Select Windows Credentials.
    3. Find entries for git:https://github.com and click Remove.
  • macOS:
    1. Open Keychain Access (use Command + Space and type it).
    2. Search for github.com.
    3. Right-click the entry and select Delete "github.com".
  • Linux (Command Line):
    • Run: git config --global --unset credential.helper.
    • If you used the "store" helper, delete the credentials file: rm ~/.git-credentials

**But sometimes this step does not work. For that use following:
git remote set-url origin https://github.com


Step 2: Set the Token in your Terminal
Since you already cleared your Keychain earlier, Git will now ask you for the new token the next time you try to connect.
  1. In your terminal, run:
    git pull origin main
  2. Username: Type your GitHub username and press Enter.
  3. Password: Paste your new PAT and press Enter.
    • Note: The terminal will not show any dots or characters while you paste. This is normal security behavior.
But in my case I was getting an error - git pull origin main says fatal: repository 'https://github.com/' not found



Run this command to fix it (replace your-username and your-repo-name with your actual names):
bash
git remote set-url origin https://github.com
Use code with caution.
Now, try to pull again:
bash
git pull origin main
Use code with caution.
What will happen next:
  1. It will ask for your Username: Type it and hit Enter.
  2. It will ask for your PasswordPaste your new PAT here and hit Enter. (You won't see any characters appear while pasting).
Why it says "Not Found":
In your previous steps, the remote URL accidentally got set to https://github.com/. GitHub doesn't see any code there, so it tells you the "repository" doesn't exist. Pointing it back to the full URL fixes this. eg: git remote set-url origin https://github.com/Anwar/Artudio

    Permissions Required for Your PAT
    Depending on which type of token you created, ensure these settings are enabled:
    • Fine-grained Token (Recommended):
      • Repository access: Select "Only select repositories" and choose your specific repository (e.g., Anwar-Faiz/artudio), or select "All repositories".
      • Permissions: Under "Repository permissions", find "Contents" and change the access to Read and Write.
      • I also give Pull Request Read and Write
      • Metadata: as Read only


Wednesday, May 13, 2020

How to update git password on terminal: Command line utility to reset github password / access credentials

On macOS, you can use

git config --global credential.helper osxkeychain

A username and password prompt will appear on your next Git action (pull, clone, push, etc.).
Eg: If you do git clone: gttps://mfaiz@www.repository.git .

As soon as you press Enter key, you will be prompted for a password.
You can use the updated password here. And, you will be able to access and password also gets updated automatically!


For Windows, it's the same command with a different argument:

git config --global credential.helper wincred


Isn't this simple :)
Cheers.

Friday, May 1, 2020

Creating new folders in GitHub repository via the browser

If you look into the Github repository online you will see that there is no direct method to create a folder. You can create a file or even upload it directly from the browser, but there seems to be no way to create a directory.
However, I have found that to make a new folder in the GitHub repository from the web browser interface, there exists a way Actually, it's just the same as creating a new file.
Steps:
1. Go to create a file

2. give the name of the folder that you want to create eg:
data/
It will create a folder named 'data'


3. If you want another nested folder then give another name eg.
airport-codes/
It will create another directory 'airport-codes' in 'data'


4. Next, create a file there. This can even be a temporary file that you can subsequently delete if you do not want it.

To see this in action refer:

Cheers :)

Sunday, May 14, 2017

Using Github ReadMe opened programatically : How to open and read the ReadMe.md file dynamically


It is noteworthy to understand that HTML does work in the ReadMe.md file. With this clear understanding, I guess many of such questions would be automatically answered like - how to make bold font in ReadMe file, or how to insert image etc. Also note that it depends a lot on what application/ text editor you are using and also lot on the OS. 


Recently I had trouble in inserting blank line character in the Readme.md file of Github. I personally preferred < br /> tag there, and i have a full post describing the same: http://www.w3lc.com/2017/05/new-line-in-readme-file-github-fixing.html.


I have demonstrated the change in a git commit in the Github repository explained in the post. See: https://github.com/Anwar-Faiz/Simple-Java-Unicode/commit/85bd54531067ff4055c5e8801aba5324221d5ae3



This understanding was much needed to handle the question and also to find many other uses of why you would probably need to do it!



Further, to answer the question straight, you need two steps: 

1. Find the Url for the ReadMe.md file in Raw version. For example see one: https://raw.githubusercontent.com/Anwar-Faiz/forkrap/master/README.md 

How to open Raw view of ReadMe.md file: ( See screenshot )



2. Now if you want to use server side the using file_gets_content etc of php you can load the url. Or, if you want to use jquery, you can use the Load().



** Do, also notice that if you do View Source of the Raw URL page, you just see, plain text. So, you don't need to do much text parsing stuffs as well :) This is a good news.

** Next you can use unescape functions or tools like codebeautify to unescape the characters that can alter with the look and feel of your HTML like ' <   " etc etc.



Using Github ReadMe opened programatically : How to open and read the ReadMe.md file dynamically: https://www.w3lc.com/2017/05/using-github-readme-opened.html

To create sophisticated formatting for your prose and code on GitHub with simple syntax, you can refer the basic writing and formatting syntax at: https://help.github.com/articles/basic-writing-and-formatting-syntax/


Have a great Day dear :)

@Anwar Jamal Faiz


Saturday, May 13, 2017

New line in ReadMe file Github: Fixing the blank new line break issue in ReadMe.Md files in Github

This post is aimed to fix a very simple issue - Fixing the blank new line break issue in ReadMe.Md files in Github. You can find the ReadMe.Md file which had this problem and how it was fixed in my Github repository: https://github.com/Anwar-Faiz/Simple-Java-Unicode


When editing an issue and clicking Preview the following lines in Read me file:
a
b
c
i.e. it shows every letter on a new line.

However, it seems sometimes that after pushing similar markdown source structure in README.md joins all the letters on one line.

Issue: This usually happens because of different Operating systems and text editors used.


Solution:
Interpreting newlines as
used to be a feature of Github. But recent documentations do not list this as a feature. So, you have to do it manually. But its easy!

Method 1: Introduce a __ character at end of each line. _ acts as a blank space
i.e transform:
a
b
c
as following in the ReadMe.md file:
a__
b__
c
(where ).

Method 2: Explicitly add
tags.
Eg:
a
b
c


I personally prefer method 2 for a number of reasons. For example you can see following commit of mine just to fix the same issue:
https://github.com/Anwar-Faiz/Simple-Java-Unicode/commit/85bd54531067ff4055c5e8801aba5324221d5ae3


Using Github ReadMe opened programatically : How to open and read the ReadMe.md file dynamically: https://www.w3lc.com/2017/05/using-github-readme-opened.html

New line in ReadMe file Github: Fixing the blank new line break issue in ReadMe.Md files in Github
https://www.w3lc.com/2017/05/new-line-in-readme-file-github-fixing.html

To create sophisticated formatting for your prose and code on GitHub with simple syntax, you can refer the basic writing and formatting syntax at: https://help.github.com/articles/basic-writing-and-formatting-syntax/

Cheers ;)
Anwar Faiz