in my .gitignore
, I have:
*.framework
*.a
However, I am using symlinks to these in various projects and since the symlinks and in .a
or .framework
, I can't seem to check those into Git.
Is there a command that I am missing or a work-a-round? I would like to check in the symlinks so that I don't have to create them each time. I could always write a bash script to make these if needed.
Git only uses the path to determine whether it should or should not ignore a file - so if it's possible to derive a pattern that captures only the files you don't want and excludes all the files you do want - that's the way to go.
However, bear in mind that git ignore rules are not set in stone; it's always possible to add a file, you just need to use the --force
flag:
$ cat .gitignore
*.a
$ git status --ignored
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# bar.a
# foo.a
nothing added to commit but untracked files present (use "git add" to track)
$ git add foo.a
The following paths are ignored by one of your .gitignore files:
foo.a
Use -f if you really want to add them.
fatal: no files added
$
What seems often to be missed in this circumstance is this line in the help output:
Use -f if you really want to add them.
Making use of the force option, adds the ignored file:
$ git add -f foo.a
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: foo.a
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
$ git status --ignored
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: foo.a
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# bar.a
$