Git and XCode: Merging .xcodeproj gives binary warning - objective-c

I am working with branches and wanting to merge with my master, but the files inside of my .xcodeproj are causing huge issues.
Constantly getting errors about overriding them, that they are binary files, etc etc.
What do I need to do to never have to worry about this? It is driving me nuts!
NOTE: I have a .gitignore file in my master that ignores these files, but not in my branch. Not sure what to do about that.

In the root of the project (eg, same directory as .git), add a git ignore file
.gitignore
With a line that says
.xcodeproj
Then remove the .xcodeproj file from the repo...
git rm --cached /path/to/.xcodeproj
Then add the .gitignore file
git add .gitignore
Then commit
git commit -m "Removed .xcodeproj; added ignore pattern to excluded it"

You can use a .gitignore file to specify that file to be ignored by git.

Related

Make npm ignore folders starting by certain prefix

Right now my .gitignore files has the following rule:
demos/test**
Which seems to be working fine with Git (and github) and ignoring the following folders:
./demos/test-whatever/
./demos/test/
But when publishing to npm, those folders are not ignored and are being published.
Any way to exclude them from npm?
You may want .npmignore to keep files out of your package.
Create a .npmignore file in your root directory and add your demos/test** ignore rule to this file. For reference:
.npmignore
demos/test**
Try a .npmignore file More info

Git submodule is ignored

When I try to add a submodule via
git submodule add git#domian:repo.git contact
I get the following message:
The following path is ignored by one of your .gitignore files:
contact
Use -f if you really want to add it.
Here is my .gitignore:
# Ignore everything
*
# But not these files:
!*.py
!*.md
!*.gitignore
!.gitmodules
!contact/
It is resolved by using the suggested -f option, but I am curious why the !contact/ entry in .gitignore does not alleviate the problem.
A submodule is composed of a gitlink (a special entry 160000 in the Git repository index), and a remote URL+path in the .gitmodules.
So excluding !contact/ would still ignore the gitlink "contact" (which is not a folder contact/, but a special "file")
This would work better, and allow the git submodule add to proceed:
!contact
And if any other cause would still block the git submodule add, the next Git 2.26 (Q1 2020) will provide a more helpful error message.
I don't hit that error in your particular case (I have git version 2.21.0.windows.1).
I do hit that error when trying to add a submodule outside the parent repository, though (which apparently isn't supported):
$ git submodule add https://github.com/user/repo ../repo
The following path is ignored by one of your .gitignore files:
../repo
Use -f if you really want to add it.
Best guess is it's a bug...so adding !contact/ to your .gitignore doesn't fix it because it's not actually the .gitignore causing the problem.
What git version do you have? You can download the source code for your particular version, search for the error message (e.g. here it is in v2.21), and trace through the code to figure out what actually goes wrong.

PhpStorm automatically ignore files from .gitignore

I'm new to PhpStorm, and I'm trying to get it to automatically ignore files specified in my .gitignore file when adding a file tree to git. I know you can add ignore rules to PhpStorm itself, but I want it to use the rules from my .gitignore file.
Basically I already have a .gitignore file with ignore rules, I just want PhpStorm to follow those rules when adding files (git add) so that none of the files matching the .gitignore rules will be accidentally added to a commit.
I know in the past this has happened to me as well, so it seems a bit fragile. I never do a git add for the entire directory since it has done things like add files in the /vendor directory (which is always in the gitignore file).
But having said that, I was curious, so I did a test as I think it might be related to when things happen (like when git is engaged, or when the .gitignore is added).
I did the following steps on a new project and it worked appropriately, so maybe that will help, you can give it a try and see if it works for you as well. I am working with 2016.1.2
Create the project
Select VCS...Enable Version Control Integration and select Git
Create the .gitignore in the root directory
In the project, create a new directory called ignore
In the .gitignore, add ignore/ and the ignore directory should turn light gray
Create a.txt in the root directory
create b.txt in the /ignore directory
right click on whole project and select git add and b.txt under the ignore directory is not added, but a.txt is

GIT ignoring files in project/bin/debug folder except few files (Visual Studio Project)

This is how my .gitignore looks like:
# User-specific files
*.userprefs
!*.ini
!*.gitkeep
!*.bat
# Build results
[Bb]in/
[Dd]ebug/
What I want to achieve is to ignore all files in project/bin/debug but keep the files like *.ini *.bat and etc.
.gitignore is location in root folder:
rootfolder\project name\bin\Debug
This works well for me. Add wildcard to your folders, and define the exceptions at the bottom.
# Build results
[Bb]in/*
[Dd]ebug/*
# User-specific files
*.userprefs
!*.ini
!*.gitkeep
!*.bat
Use ! operator to negate pattern:
*.bat
!myfile.bat
In your case it's better to use .gitignore in specific directory. You should make .gitignore file in project/bin/debug with a content:
*.*
!*.bat
Or you can do it in your project main .gitignore:
MyFolder/*
!MyFolder/NotIgnored.txt
Without * it won't work.
Keep in mind that already staged files won't be ignored. You need to unstage them using git rm --cached <file>
I solved this by modifying the .gitignore of my root folder to:
# User-specific files
*.userprefs
!*.ini
# Build results
![Bb]in/
[Bb]in/*
![Dd]ebug/
Then creating another .gitignore file inside rootfolder/project/bin/debug/ directory with the ff:
*
!*.ini
!*.bat
Hope this can help someone in the future.
And btw, I got my .gitignore file from: https://www.gitignore.io/api/visualstudio

Is the .gitignore file universal/global, in Rails?

I'm a noob to RoR, so any help/clarification is appreciated.
Is the .gitignore file in Rails universal/global to all of Rails, or does each project/app have its own .gitignore?
.gitignore is a Git file, it has nothing to do with Rails.
A .gitignore file will apply to the directory it is in and any subdirectories. You can create .gitignore files in subdirectories to have them only apply to those subdirectories and their descendants.
A default .gitignore is created when you create a new Rails app. That file tells git to ignore the things that are in a default Rails app that should probably be ignored.
If there are other files that should be ignored in your specific app, you can make changes to the .gitignore. If you're not using git, you can delete the file entirely.
It's basically there to encourage best practices, but is in no way required to run a Rails app.
There's a .gitignore_global file in your ~/ directory that every git instance references.
Git is independent of rails.
the .gitignore file is restricted to the initialized repository.