I have a fairly simple question I could not find a solution for. I want to ignore all Mac OS X Alias folders I have in my git project. How do I target those? I couldn't figure out their file extension. ".alias" and ".alias-file" doesn't seem to work. Is there a way to do this? Other than ignoring each one specifically.
4 Answers
I don't know anything about git
, but this script can find OSX aliases and list them for you, so you could probably pipe the list into git
to ignore somehow...
#!/bin/bash
################################################################################
# ListAliases
# Given a directory as parameter, find and output names of all things under
# that directory that are aliases. Not an officially approved technique!
################################################################################
d=${1-$(pwd)}
find "$d" -exec sh -c 'xattr -pl com.apple.FinderInfo "{}" 2> /dev/null | grep -q alisMACS && echo "{}"' \;
Save it in a file called ListAliases
, then make it executable like this:
chmod +x ListAliases
and run it like this
./ListAliases
or
./ListAliases /path/to/git/repository
Sample Output
/Users/mark/.Trash/installed.txt alias
/Users/mark/Desktop/installed.txt alias
/Users/mark/Desktop/installed.txt alias 2

- 191,897
- 31
- 273
- 432
It sounds like you're assuming that every file needs to have a file extension... that Mac alias files have a ".alias" extension. That's not the case. The Mac OS supports files both with and without extensions. When aliasing folders, there's no file extension involved. You would need to ignore the names of the folders that the aliases point to, which in turn would ignore the aliases themselves, since the aliases share the same name as the folders they point to.

- 63
- 3
-
2Right about the fact that folders to not have the `.alias` extension. Wrong that aliases need to have the same name as the folder they point to. – orome Nov 28 '15 at 15:15
What about aliases to folders?
With regard to folder alias' I tried this and it seemed to work:
*\ alias
In this case for all folder alias'

- 31
- 3
Just create a ".gitignore" file. Write inside the patterns you want to ignore. (separated by new-line)
In your case that would be:
" .alias* "
Then, the "git status" command should not show you files OR directories matching the pattern.
Finish with a 'git add .gitignore' and "git commit -m "Added a gitignore file""
Update: Ok, the answer is very basic but I hadn't any clues. Check this link : Ignore files that have already been committed to a Git repository

- 1
- 1

- 2,617
- 18
- 19
-
1I know all about the gitignore file and how to work with it, it's just that the selector ".alias" simply doesn't work for me. Those files/folders still don't get ignored. (Certain other files do, so my file is definitely working right, just the ignore selector that is wrong). – user3573218 Jul 21 '14 at 16:48
-
Have you already tracked your files .alias* ? ie are those file in a snapshot of your git history ? – chaiyachaiya Jul 22 '14 at 11:57
-
-