1

I am attempting to view my .git directory on VSCode by entering the command to show hidden files. I understand that on a Mac, this command is: la

I've read that on Windows, the equivalent command is: ls -la

However, after entering this to the VSCode terminal I am faced with the following error:

Error which appears

What am I doing wrong ?

  • 1
    `la` is just an alias for `ls -la` on some systems. `ls -la` will work under Git Bash on Windows or on any Unix system (including WSL). Your problem is that you're trying to use PowerShell instead of Git Bash. – bk2204 May 30 '20 at 19:37
  • look at this question [How to show hidden files (dotfiles) with windows powershell](https://stackoverflow.com/questions/50817139/how-to-show-hidden-files-dotfiles-with-windows-powershell) – SwissCodeMen May 30 '20 at 21:05
  • You can change the default terinal from powerhell to git-bash by following along the answer given here https://stackoverflow.com/questions/42606837/how-do-i-use-bash-on-windows-from-the-visual-studio-code-integrated-terminal. Then the 'ls -la' command should work. – vpp Sep 21 '21 at 20:51

4 Answers4

2

@siddart: You are unfortunately incorrect on how you show hidden (dotfiles) files in the terminal/command line on macOS. In order to access hidden files/folders on macOS it is actually ls and if you want to find hidden files/folders on macOS, then you use: $ ls -a

Next, you are referring to PowerShell as compared to just the Command Prompt. cmd

Be aware: There is a difference in the commands and arguments in Powershell as compared to the Command Prompt.

So with that all taken care of, the actual way to do it in Windows via Command Prompt should be exactly the same as it should be in the VS Code terminal.

The folks over at Minitool show 4 different ways to show hidden files from their example, I'll only show you the one from the CMD Prompt.


How to Show Hidden Files Windows 10 with CMD

You can open Command Prompt in Windows 10 to show hidden files with attrib command.

Detailed steps are as follows:

  • Step 1. Press Windows + R, type cmd, and press Ctrl + Shift + Enter to open elevated Command Prompt in your Windows 10 computer.

  • Step 2. Then you can type this command line: attrib -h -r -s /s /d E:\*.*, and hit Enter to unhide the files and folders in drive E. You should replace the drive letter with the exact drive letter of your computer. You can open This PC to check the drive letters of your computer hard drive partitions.


C:\Windows\system32>attrib -h -r -s /s /d E:\*.*

Show hidden files cmd

To help you better understand this attrib command, below is the explanation of each part of the command line.

  • –h: It clears the Hidden file attribute to show hidden files.
  • –r: It clears the Read-only file attribute to allow you modify the file after it shows.
  • –s: It clears the System file attribute.
  • /s: It applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.
  • /d: It applies attrib and any command-line options to directories.

@Siddart I hope that answers your question.

Community
  • 1
  • 1
1

When in the Powershell on Windows you must use dir -force to show all files including hidden git files. dir is the command to show your normal files and dir -force shows all.

Sunhound91
  • 11
  • 1
0

Either use

Get_ChildItem . -Force

or use

ls -Force

It'll work.

0

Depends on the shell. If you are in cmd, you would want to use

dir /a

to see all files and folders including the hidden items.

Bernhard Döbler
  • 1,960
  • 2
  • 25
  • 39