103

By default it is not possible to see .gitignore files in osx. What is command to reveal these files?

Jay
  • 2,715
  • 8
  • 33
  • 33

10 Answers10

182

Open the terminal and type

  • on OS X 10.8:

    defaults write com.apple.Finder AppleShowAllFiles TRUE
    
  • on OS X 10.9:

    defaults write com.apple.finder AppleShowAllFiles TRUE
    

Then you must relaunch finder:

killall Finder

Any file name in OS X prefixed with a '.' is considered "hidden".

steve84
  • 213
  • 3
  • 8
Snarf
  • 2,251
  • 1
  • 15
  • 17
  • 7
    This command will show all hidden files, is there a way to actually make the specific files always visible ? – Roland Feb 25 '14 at 08:05
  • See prodigitalson's answer. – Snarf Feb 25 '14 at 23:25
  • So there is no way to make it global unfortunatelly, thanks @snarf – Roland Feb 26 '14 at 10:07
  • Check out [this post](http://apple.stackexchange.com/a/115009/77639) on AskDifferent that has AppleScript for toggling hidden files. You can use Automator to create a service that runs that script and assign a keyboard shortcut to that service so you can quickly toggle on and off hidden files. – shim Aug 11 '14 at 21:53
  • This command isn't working on Yosemite or El Capitan.This is the right answer http://stackoverflow.com/a/29219426/1803863 – Andrew Oct 17 '15 at 19:56
  • Even after showing hidden files, if your are not able to found .gitignore file then simply in terminal type `touch .gitignore` in this directory. This will create new gitignore file. – Muhammad Umair May 20 '16 at 12:09
  • just out of curiosity, what is the difference between the commands for OS X 10.8 and 10.9? they look exactly the same, am I missing something? – Can Poyrazoğlu Sep 05 '16 at 08:38
  • 1
    @CanPoyrazoğlu lower vs uppercase "F" in `com.apple.Finder` – Snarf Sep 05 '16 at 16:56
  • You can also restart the finder by going to Apple -> Force quite -> Finder -> restart – Maarten Jul 15 '17 at 18:56
77

You can use the shortcut in Finder:

Command + Shift + .

It will show the hidden files. To hide the files again, use the same shortcut.

finefoot
  • 9,914
  • 7
  • 59
  • 102
DevAnuragGarg
  • 1,592
  • 2
  • 14
  • 18
54

⌘⇧. will toggle the AppleShowAllFiles setting.

This key combo will work from open/save dialogue boxes in all apps, not just the finder. Use this and you’ll never be confused when on someone else’s Mac or a new Mac, and you can avoid mucking around with defaults write.

I use the nemonic of “use a dot to show a dot file” to remember it, because of hidden dot files in unix.

roosto
  • 843
  • 8
  • 9
18

if you just want to look at them you can always use the command line:

ls -al path/to/dir

If you want to always view all files from the finder you can do:

defaults write com.apple.Finder AppleShowAllFiles YES

If you just want to view a .gitignore from the finder you can:

chflags nohidden /path/to/dir/.gitignore

But youll have to call that command on every .gitignore its not global.

patridge
  • 26,385
  • 18
  • 89
  • 135
prodigitalson
  • 60,050
  • 10
  • 100
  • 114
16

(more recent, for 10.10.2:)

The above commands didn't work for me. I'm using OSX Yosemite: 10.10.2. This worked though:

defaults write com.apple.finder AppleShowAllFiles -boolean true;
killall Finder;

Source: http://www.idownloadblog.com/2014/08/04/how-to-show-hidden-files-folders-finder-mac/

Sze-Hung Daniel Tsui
  • 2,282
  • 13
  • 20
  • hey there thanks for the post. If someone is trying to use this, then I had success using the following command line: "defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder". Otherwise, it does not work. – serge-k Nov 10 '15 at 23:53
  • Is there a way to show just the file starting by dot "." but not the system file? –  Dec 05 '15 at 15:33
9

You can edit hidden file in terminal using this command

open -a TextEdit .gitignore 
Cong Dan Luong
  • 1,577
  • 17
  • 15
1

If you just want to view a .gitignore from the console just type "nano .gitignore" in that directory. This command "nano" simply opens any textfile in nano console environment for viewing or editing

akcasoy
  • 6,497
  • 13
  • 56
  • 100
1

In addition to the accepted answer, you can create an alias to easily show/hide the hidden files in Terminal. This is how I set it up (tested/working on macOS Mojave 10.14.1).

In my user directory I created a new file .custom_aliases and wrote this in:

# Show/hide files
alias showall='defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder'
alias hideall='defaults write com.apple.finder AppleShowAllFiles -boolean false; killall Finder'

Next I opened .bash-profile (should also be in your user directory, if not just create it there) and added this to the top of the file:

# Load custom aliases
source ~/.custom_aliases

And that's it! Now whenever I need to view the hidden files I just type showall in Terminal and hideall when I'm done. You could also define the aliases directly in the .bash_profile, but I have some other stuff so I like to keep all the aliases together in a separate file.

0

Show hide file and folder on MacOs Mojave 10.14.4

Apply at Terminal

defaults write com.apple.finder AppleShowAllFiles -boolean true;
killall Finder;
Shomu
  • 2,734
  • 24
  • 32
-4

It's possible you might just not have a .gitignore file. If you don't have one, you can create it like this:

>touch ~/.gitignore

And then edit it however you'd like. Git will automatically check this file, without any additional configuration!

Billy Lazzaro
  • 476
  • 2
  • 13