.gitignore for xcworkspace, not just xcodeproj? - xcode

I have a .gitignore file in MyProject.xcodeproj which ignores the xcuserdata, but the directory is not ignored in my MyProject.xcworkspace and I can't figure out how to do it there? Any suggestions?

Make sure the content of that folder is not already tracked:
git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata/*
git commit -m "Removed previously track xcuserdata content"
Then your .gitignore would apply automatically.

Related

Git on Windows: How do I ignore a folder that has dots in its name

I have a directory like that :'dir1/dir2/blah.blah.blah.blah/'
'blah.blah.blah.blah' is folder how do I add it to .gitignore?
I tried:
dir1/dir2/blah.blah.blah.blah/*
You need to escape the . in your .gitignore file like this:
blah\.blah\.blah\.blah
If this does not work, you probably added the directory to git earlier. In this case, you need to remove it from git (git rm <directory> and then git commit) but this will also remove it from the working directory, so backup the files if you still need them!
Use git ls-files dir1/dir2/ as suggested by torek in the question's comments to check if the directory has been added to git.
To remove a file or directory from repository, you can use this:
git rm -r --cached <file/directory>
git commit -m "removes <file/directory>"
This will not remove anything from the history though. The files can still be accessed when checking out an older commit.
It will also not remove the actual files in the directory, it will just make git not longer track them.

How can I make Xcode ignore xcodeproj in Xcode 9?

I have been working on a C project using Xcode9. I don't want to push my .xcodeproj directory into the GitHub. I use the source control menu inside the Xcode to sync with GitHub.
I have added the following line into my .gitignore file:
*.xcodeproj/
DerivedData/
*.pbxproj
*xcworkspace
but it won't work. When I commit, Xcode would still push my xcodeproj directory into the GitHub. How can I ignore these files in Xcode9.
That might be because those files are already tracked (making the .gitignore directive moot)
Try and remove them from the index
git rm --cached -r *.xcodeproj/
git rm --cached -r DerivedData/
git rm --cached -r *.pbxproj
git rm --cached -r *xcworkspace
The --cached option will make sure you keep those files on the disk (and remove them only form the index).

Can't get Xcode / JUCE / .gitignore to work

I'm placing my .gitignore file in the same location as the *.jucer file and the .gitignore file contains:
./Builds/*
./JuceLibraryCode/*
As I only want to back up the source code folder only.
But whenever I go to commit, tons of of folders and items inside the Builds and JuceLibraryCode folder are pre checked. How Can I get Xcode to see this ignore file? Is it in the wrong location since the Projucer builds the folder hierarchy in a way that Xcode doesn't understand? I have it in the same location as my .git file.
Also, its worth noting that I recently allowed .git to back up everything, all of the files I'm currently trying to now ignore in those folders, but I did do a git rm --cached on all the files I'm trying to skip, as i read I needed to dump those before the .gitignore would be successful, but still, not luck. Any help would be greatly appreciated.
Remove git cache again.
$ git rm --cached -r .
Add this in .gitignore
Builds/
JuceLibraryCode/
See if git ignore the changes
$ git status

.gitignore files not working (ignore .DS_Store file in Mac OS)

I have create a.gitignore file at my ~ path by this code in my terminal:
touch ~/.gitignore
and also add this file and git defining excludes file by below code:
git config --global core.excludesfile ~/.gitignore
and then remove all of my .DS_Store file using below command
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
(every file has been removed successfully and if I open xCode and press commit the D label appears near this files)
Before I commit I add the .DS_Store to the .gitignore file by this command:
echo .DS_Store >> ~/.gitignore
it also works and write the value in the file but it is not working. Because when I back to xcode and commit the files and then back to finder and navigate to folders and back to xcode, I can see the .DS_Store files in commit dialog too.
Does someone have any idea about what is the problem?
After performing the
git rm
you still need to commit those changes
git commit -m "deleted all .DS files"
The next time you will ask git for a diff, these files will no longer show up as modified or "new" because they are in your global gitignore file

git not ignoring folder specified by .gitignore

I am using the .gitignore file from here but I still am still finding that
CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate
is staged for a commit?
Why isn't the folder xcuserdata excluded?
Did you already commit after adding .gitignore to tracking files?
git rm -r --cached .
git add .
git commit -m ".gitignore is now should working"

Resources