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

Pages










Saturday, February 28, 2026

How To undo a git add operation (unstage files)

To undo a git add operation (unstage files), the recommended command is git restore --staged. This moves changes from the staging area back to the working directory without losing any modifications.

Recommended Method: git restore --staged
This command is the preferred method in modern Git (versions 2.23+) because it is more intuitive and safer for this specific task.
  • Unstage a specific file:
    bash
    git restore --staged <filename>
    
    (Replace <filename> with the actual name of your file, e.g., git restore --staged index.html).
  • Unstage all files:
    bash
    git restore --staged .
Alternative Method: git reset
Before git restore was introduced, the git reset command was used to unstage files, and it still works.
  • Unstage a specific file:
    bash
    git reset <filename>
    
  • Unstage all files:
    bash
    git reset

How To change a Git branch name

To change a Git branch name, you first rename the branch locally using git branch -m and then update the remote repository.

Renaming a Local Branch
You can rename a local branch in one of two ways:
  • If you are on the branch you want to rename:
    bash
    git branch -m <new-name>
    
    For example: git branch -m feature/new-login.
  • If you are on a different branch:
    bash
    git branch -m <old-name> <new-name>
    
    For example: git branch -m feature/old-login feature/new-login.
Renaming a Remote Branch
Renaming a branch that has already been pushed to a remote repository (like GitHub or GitLab) requires a few extra steps and team coordination.
  1. Rename your local branch using one of the methods above.
  2. Push the newly named local branch to the remote repository. This effectively creates a new branch on the remote.
    bash
    git push origin -u <new-name>
    
    The -u (or --set-upstream) flag is important as it links your local branch to the new remote branch.
  3. Delete the old branch from the remote repository to avoid confusion:
    bash
    git push origin --delete <old-name>
    
  4. Update settings on your Git host (e.g., GitHub, GitLab, Bitbucket) if the renamed branch was the default branch or if there were branch protection rules, CI/CD pipelines, or open pull requests associated with the old name.

Monday, February 16, 2026

My Code Disappeared After Switching Branches — Here’s What Actually Happened

 Yesterday I panicked.

I switched from a feature branch back to main in Git…

…and my fix was gone.

The file didn’t show the changes.
The bug fix disappeared.
I thought I lost my work.

If this has ever happened to you — relax.

Your code probably isn’t lost.




😰 What Actually Happened?

I had:

  • Created a branch: feature-x

  • Fixed a bug

  • Committed the fix

  • Switched back to main

When I checked the file in main, the fix wasn’t there.

Why?

Because Git branches are independent timelines.

My fix existed.
Just not in main.


🧠 The Important Concept

Think of branches like parallel universes.

When you commit inside feature-x, that commit belongs to that branch.

Switching to main doesn’t magically bring those commits with you.

You must merge them.


✅ How I Fixed It

I ran:

git checkout main git merge feature-x

Boom.

The changes appeared.

Then I pushed to GitHub:

git push origin main

Problem solved.




🔎 How To Debug If This Happens To You

Here are the commands that save you:

1️⃣ Check where you are

git branch

2️⃣ See commits across branches

git log --all --oneline --graph

3️⃣ Compare branches

git log main..feature-x

4️⃣ Recover “lost” commits

git reflog

Nothing is usually lost.
It’s just on another branch.


🚀 Lesson for Developers

Before panicking:

  1. Check your branch

  2. Check your commits

  3. Understand Git timelines

  4. Merge properly

  5. Push if needed

Git rarely deletes your work.
It just organizes it.


💡 Final Thought

The biggest Git mistake is not a wrong command.

It’s not understanding branches.

Once you understand that each branch is a separate history —
Git becomes predictable.

And panic disappears.

Sunday, February 15, 2026

how to check apache server and php installed or not on mac

 macOS comes with Apache pre-installed, though it may not be enabled by default. You can check its installation and status using the Terminal with the following commands:

  • Check the Apache version: Running the apachectl -v command will display the installed Apache version and build date, which confirms the software is present.
    bash
    apachectl -v
    
  • Check if the Apache service is running: Use sudo apachectl status to see the current status of the Apache service. You can also use the ps aux | grep httpd command to list all running processes related to Apache's executable (httpd).
    bash
    sudo apachectl status
    # or
    ps aux | grep httpd
    
  • Verify the installation via web browser: If the service is running, open a web browser and navigate to http://localhost. If you see the message "It works!", then Apache is installed and serving web pages correctly.
  • Locate the Apache binary: The which command can show the location of the Apache executable in your system's PATH, which is typically /usr/sbin/httpd for the default macOS installation.
    bash
    which httpd
    # or
    whereis httpd
    
If these commands do not work, Apache may not be correctly configured or installed on your system. In such cases, you might consider installing it via a package manager like Homebrew.