Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:45:04+00:00 2026-05-24T01:45:04+00:00

I have a branch called develop in remote bare repo hub , and I

  • 0

I have a branch called develop in remote bare repo hub, and I have a checkout copy of the develop branch in my local git repository (user poomalai).

I have deleted (git rm --cached) a file (Mydirectory/myfile.php) from another checkout copy (user raj), and pushed to the hub repository.

Now, when I pull the changes from the hub to (user poomalai), it works fine, and I have the commit message file deletion in the git log.

I have added the file in the .gitignore file in the (user poomalai).
Now I have created the file in my local repo (user poomalai).

Now the file is no longer in the version control, and changes to the file is not tracked by git.

But when I try to switch to some other branch it says the following:

error: The following untracked working tree files would be overwritten by checkout:
Mydirectory/myfile.php
Please move or remove them before you can switch branches.
Aborting

When I remove the file using linux rm command, I am able to switch branches.
If I create the file again, it again throws the same error.
I need the file to be in the directory but it should not be tracked by git.

I tried following commands:

git rm  

fatal: pathspec ‘diamonds_webservice/dbconnect.php’ did not match any files

git gc
git reset --hard HEAD
git pull

Nothing works. Please someone help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:45:07+00:00Added an answer on May 24, 2026 at 1:45 am

    This could be possible because the the file is added to the repo in the ‘target branch’.
    Ensure that the file is git rm‘ed from the ‘target branch’, and then try switching branches.

    As @CharlesB said, git does it to ensure data integrity, so that nothing is lost when switching directories.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a branch called experiment. git checkout master echo 'some changes' > a.txt
I've read this book section about git branches. I have create a branch called
Here's the scenario: I have a local git repository that mirrors the contents of
I have an SVN repository where I have trunk and a branch. I intend
I'm merging in a remote branch that may have a lot of conflicts. How
I have created a branch called feature3 from my trunk. I make zero modifications
I have a central repository and 3 users with local repositories that pull and
Using subversion 1.5 I have branch B which was branched off of branch A.
I have a branch in an SVN tree which contains the source to a
In svn, I have a branch which was created, say at revision 22334. Commits

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.