Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git status picking up parent folder's files

Tags:

git

I've just created a new project in htdocs/project and when I use a status to pick up the files in that folder it is listing the files and directories contained in htdocs/project but it is also listing all the folders and children of htdocs as well.

For example:

# Changes not staged for commit:
#    modified:    ../otherproject/index.php
#    modified:    ../project3/index.php

# Untracked files:
#    ../otherproject/blah.txt
#    ../project3/img/lol.jpg

If it helps I used the "Git Bash Here" option to change my Git directory to htdocs/project.

like image 753
heritikyl Avatar asked Mar 21 '12 21:03

heritikyl


1 Answers

Is 'htdocs' itself a git repo?

ls htdocs/.git

If so, that would explain what you're seeing - a git repo can't have another repo within it.

(Posted as an answer rather than a comment because I don't have enough persimmons.)

Edit: Based on the discussion below, this seems to be the problem. According to http://progit.org/book/ch6-4.html:

Making a Subdirectory the New Root

Suppose you’ve done an import from another source control system and have subdirectories
that make no sense (trunk, tags, and so on). If you want to make the trunk subdirectory be 
the new project root for every commit, filter-branch can help you do that, too:

$ git filter-branch --subdirectory-filter trunk HEAD

Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12)
Ref 'refs/heads/master' was rewritten
Now your new project root is what was in the trunk subdirectory each time. Git will also 
automatically remove commits that did not affect the subdirectory.

I haven't done this myself, so hopefully someone who has will volunteer some experiences.

like image 81
jimw Avatar answered Oct 14 '22 07:10

jimw