Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Issue with Source Tree not finding sub-directories

MIke Neill August 13, 2012

Hi, I have an Xcode project where I added the library RestKit as a sub-directory of my project. The issue I'm seeing is that SourceTree will not recongize the new directory at all in my working copy. Do you guys have any thoughts on why this would happen?

4 answers

3 votes
Dan Bishop October 4, 2012

For what its worth, I just experienced the same issue on my machine. I dragged & dropped a folder that contained some .h and .m files, plus a Readme.md file into my Xcode project (using Finder), then added the files to my project (within Xcode).

SourceTree was completely unaware of any file inside the sub-folder that I had added. This could have caused a serious issue for me, as I thought all my files were committed to the index and pushed to GitHub. I only discovered the problem after deleting and re-cloning my repo (which I did for an unrelated reason).

I tried the usual CMD+R, changing the UI to Show All, Show Uncommitted, etc, but nothing worked. I verified that my .gitignore had nothing even remotely close to the files/folder that I had added.

The one thing I will say is that the folder I copied in was originally setup as a separate repository in SourceTree. Is it possible that SourceTree thought the files were part of a sub-module/sub-repository, and tried to "helpfully" prevent them from being added to the index?

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2012

Yes, if you have a .git folder in any subfolder, git will totally ignore it because it considers that whole tree to be a nested repository that looks after its own files. This isn't a SourceTree feature, this is something git always does when you use 'git status' (and hg does the same FWIW).

So if you copy files around that you intend to add to a repo (rather than as a submodule), it's really important not to copy any .git or .hg folders with it. Can be tricky I know, since Finder doesn't show them by default and will implicitly take them if you copy the parent folder.

Like deelakameegoda likes this
Alexei Akimov November 1, 2017

This is what solved it for me.  I had buried .git files inside folders which I dragged-in.  After doing   "ls -la" to show all files, and doing "rm -rf .git" on the unneeded git files (those inside the sub-folder, not the main .git file on the repository top level), all the new files and folders are now tracked. 

Like # people like this
Chris Lanning April 16, 2018

Yep, buried .git folders is what killed me.

1 vote
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2012

This should only happen if there are no files inside the folder, or if every file was ignored by either your global ignore file, or the local ignore file.

You can use Cmd-R to force a refresh if you want to make sure that's happened, but if not it'll be that. You can check what ignored files there are in a repository by switching the file filter to 'Show Ignored' (it defaults to 'Show Pending', which includes unknown files so long as they're not ignored).

MIke Neill August 13, 2012

Ok, I have verified you guys have a bug. What I did to resolve my problem was I completely emptied the RestKit folder, then I created a simple TXT file called "readme.txt" and added it into the RestKit folder. When I did that then SourceTree started to see the RestKit directory. I then re-added all of the RestKit files back into that folder, and SourceTree saw those files as it should have done in the first place. I think there may be a logical error in the process that checks directories for files. Purhaps you guys need to take a look at that.

Thanks

MIke Neill August 13, 2012

I tried a cmd-R refresh, and I also looked at the show ignored, but the RestKit folder isn't showing up anywhere. The RestKit folder has several sub-directories and an Xcode project file in it. I did noticed a similar issue earlier this morning when trying to add in a folder that contained two sub-folders. The sub-folders did have files, but nothing ever showed up in SourceTree. I think you guys have a bug.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2012

I've just run a test here in both Mercurial and Git:

  1. Take a clean repo with no changes
  2. Set the view options to 'Show Pending' and clear the Search filter box
  3. In a terminal for this repo:
    mkdir folder1
    mkdir folder1/folder2
    echo "Test" > folder1/folder2/testfile.txt
  4. Switch back to SourceTree

The result is an auto-refresh and a new untracked file 'testfile.txt' shows up in the folder 'folder1/folder2'.

I really do think you must have something in your ignore files which is causing this, because I can't replicate your issue here. I also use XCode projects regularly - they just look like regular folders to SourceTree, just like they do to git/hg and the terminal.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2012

Sorry, you replied while I had the page open so we overlapped.

Here's the thing - the untracked files are reported by 'git status' or 'hg status', they're not at any time queried manually by SourceTree (if we did it ourselves we have to replicate the ignore behaviour). So there's no filtering or iteration in SourceTree to fix.

I re-ran my test with a copy of RestKit instead of creating folders myself. It worked perfectly when I moved or copied the RestKit folder in, here's the video: http://www.screencast.com/t/5XPXWCNpm

So, I can't replicate this behaviour.

0 votes
deelakameegoda July 11, 2019

There must be a .git folder inside the directory that you've copied. Get rid of that unwanted .git folder and you'll be able to see the unstaged files in the sourcetree.

0 votes
super0 November 19, 2018

Got the same issue, SourceTree didn't saw any of subfolders as "ProjectNameFolder" and "PodsFolder" inside my project folder. After trying to create new folders, move all files into them, removing unseen folders and rename new folders with default names, SourceTree started to track them with all files within. There were no filters or gitignore files or anything that could cause this issue with my preferences. Just strange standard subfolders block.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events