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 git. Show all posts
Showing posts with label git. 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, February 11, 2026

Top 5 Blogposts / patterns of all times on W3LC - A true analysis for from a Technology Blogger

Recently I sat to analyze what has worked well for my blog and what topics were the most helpful based on the number of visits per post. 

Following 5 clearly stood out as the Top 5 patterns of all times.

 

🔥 1. Clear #1 Winner Pattern: “Quick Linux / System Fix”

Topic: Checking File system / Directory size in Linux (df -k, du -sh)

Visitors - 301K visitors


Why it exploded:

  • High search intent (“I’m stuck NOW”)
  • Very specific command
  • Short, practical, copy-paste friendly
  • No philosophy, no fluff

👉 This is classic evergreen DevOps traffic


URL: https://www.w3lc.com/2013/05/checking-file-system-directory-size-in.html



🔥 2. Windows + Enterprise IT Pain

Topic: RDP full screen MSTSC and Disable RDP wallpaper via Group Policy

 

Visitors -

RDP full screen MSTSC - 81K visitors

Disable RDP wallpaper via Group Policy - 17K visitors


Why these work:

  • Corporate IT users
  • Windows admins Google exact phrasing
  • Very few blogs explain this simply

👉 Enterprise IT problems = loyal Google traffic


URLs: 

https://www.w3lc.com/2014/04/rdp-in-full-screen-mode-remote-desktop.html

https://www.w3lc.com/2012/09/disable-remote-host-desktop-wallpaper.html



🔥 3. Errors & Weird Messages = Hidden Gold

Visitors - 

Error 452 file larger than ulimit - 30K visitors

Git cherry-pick bad object - 16K visitors

Perl XML/Simple.pm @INC - 7K visitors


Why they work:

  • Exact error text in title
  • User pastes error into Google
  • The blog becomes “the savior page”

👉 Error-first titles are the silent traffic engine


URLs: 

https://www.w3lc.com/2011/11/error-452-error-writingfile-larger-than.html

https://www.w3lc.com/2017/03/fatal-bad-object-error-in-git-cherry.html

https://www.w3lc.com/2012/03/cant-locate-xmlsimplepm-inc-inc-in-perl.html

 


⚠️ 4. General Information and novelty of the Blog!

Visitors - 

Definition of Smart Devices – 62K

Why W3LC blog – 25k


Why it was read by people:

  • Informational / opinion-based
  • Less urgency
  • Not a “problem to fix”

👉 These are good for branding, not aimed for traffic spikes. Yet it drew!


URLs:

https://www.w3lc.com/2018/07/definition-of-smart-devices-by-w3lc.html

https://www.w3lc.com/2010/05/why-new-it-discussions.html

Tuesday, March 23, 2021

How to undo a Git Add Command befor any commit

 This is a very simple mistake by developers that they accidentally add a file locally using the Git add command.


Sometimes a git add * command also adds all the files. What to do in such situation is the aim of this post.


Let's take an example:

Suppose, I mistakenly added files to Git using the command:

git add anwar-jamal-faiz.txt

I have not yet run git commit. Is there a way to undo this, so these files won't be included in the commit?

You can undo git add before commit with


git reset <file>

eg: git reset anwar-jamal-faiz.txt

which will remove it from the current index (the "about to be committed" list) without changing anything else.


You can also use: git reset

without any file name to unstage all due changes. This can come in handy when there are too many files to be listed one by one in a reasonable amount of time.


Cheers ;)


Wednesday, June 24, 2020

Git: How to discard all local commits on branch And making local same as upstream branch

Discarding all local commits on branch


In order to discard all local commits on this branch, to make the local branch identical to the "upstream" of this branch, simply run

git reset --hard @{u}



Hope this answers the question that how to discard all local commits on branch. Or, how to make  local same as upstream branch


Read some of my other posts related to Git tricks below :

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 :)

Tuesday, May 7, 2019

Git password expired. How to reset git authentication?


Sometimes, when you try to git clone the git repository or do any push or pull, it says:
remote: HTTP Basic: Access denied  fatal: Authentication failed for "~~yourRepositoryName"

The simplest reason is that your password is expired and/or changed externally. And, you need to change it for git to understand.

So, the question comes that How can you re-access your git repository or simpley put - How will you reset the password credentials.

Solution: Cheers, its simple.

Command:
git config --system --unset credential.helper

This will start resetting your credential manager stored wrong authentication password. Will ask for new password.
And, that's it. Enjoy.



---- I have found another method and updating it here on 30 January, 2020 ----


To fix this on macOS, you can use
git config --global credential.helper osxkeychain
A username and password prompt will appear with your next Git action (pull, clone, push, etc.).
For Windows, it's the same command with a different argument:
git config --global credential.helper wincred
The above trick resets the password stored. After this when you git pull, it will ask for password.



:)

Tuesday, January 22, 2019

How to undo a Git commit that was not pushed

To undo a Git commit that was not pushed, you are given a few major options:

Method 1:
Undo the commit but keep all changes staged
git reset --soft HEAD~; 


Method 2:
Undo the commit and unstage the changes
git reset HEAD~; 
or 1 git reset --mixed HEAD~; 


Method 3:
Undo the commit and lose all changes
git reset --hard HEAD~;


Method 4:
In case you just want to rewrite the commit message, you could use:
git –amend instead.

eg: git commit --amend -m "an updated commit message"



However if you only want to undo Last Git Commit

Then easiest way to undo the last Git commit is 
$ git reset --soft HEAD~1


I will add following more helpful commands to check commit history, go back to a commit, and remove commits etc:
  1. git log
  2. git log --oneline to simplify the output:
  3. To test a specific commit: git checkout . You will be in 'detached HEAD' state. You can look around, make experimental changes and commit them, even create a new branch from here using git checkout -b new_branch_name
  4. To fix the detached head issue: git checkout
  5. Undo this commit: git revert . This will create another commit operation in github

Free Additional Tip:
To Undo a git add i.e. remove files staged for a git commit
1. git reset filename.txt OR
2. git reset *
After this you can add again the required files


Cheers :)
-Anwar Jamal Faiz


Read some of my other posts related to Git tricks below :