Issue with Source Tree not finding sub-directories

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?

2 answers

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

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

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.

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.

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.

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?

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.

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. 

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

241 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot