Unable to change the directory using Git CMD - cmd

I'm trying: cd /e/project/
it says: The system cannot find the path specified.
But the drive and folder exists! & the same error shows to all the directory I tried to use.
note: It works with GitBash

/e/project is something MSYS emulates to be able to access the different drive letters on a Windows system. Windows itself does not have a single root directory, but multiple drive letters. This is a mismatch between Linux filesystems, which only have a single root directory (/) and Windows filesystems, which can have multiple roots, designated by their drive letter (A:, C:, D:, …).
In cmd.exe or powersell, it works differently – first you have to select the drive, then change into the directory:
C:\> E:
E:\> cd project
E:\project\>
I'm not aware of a single command to switch drive and directory at the same time. Even if you did:
C:\> cd E:\project
you need to switch the drive aftewards:
C:\> E:
E:\project\>

Related

Viewing and copying document on a laptop onto a usb only using command prompt

I am trying to download a file onto a usb from my laptop which is suffering from software issues. I used the command C:users\username>\dir documents on another pc, and was able to view the documents in the folder however, on the laptop in question, the command did not work and I was given the message "The system cannot find the path specified." I am trying to find the name of the document I need to copy so I am requesting a command which enables me to view all documents in the folder. After I find the name of the document, I am also unaware of how I can use command prompt to copy the file onto the USB i have inserted.
I am accessing the command prompt through System Recovery. I do not know code in any form. IMPORTANT Information which may be the reason for the lack of ability to do anything. When I type prompt>dir ****.docx /s /p, I get the message Volume in drive C has no label rather than Windows 7.
This could help-
http://www.dummies.com/computers/operating-systems/windows-xp-vista/how-to-search-for-files-from-the-dos-command-prompt/
As for copying files in cmd, it's as easy as-
prompt>copy <source> <destination>
For changing the drive (to the USB drive), use the "/d" option-
prompt>cd /d <USB drive name>
To view all the contents of current directory, use "dir"-
prompt>dir
Basically, you're not using right syntax. Kindly make cd c:\users and than write dir like this C:> cd C:/Users than your directory will be changed after that you can see C:/Users. So you can write dir in order to see your directories

Cannot find file to delete via git bash, but it shows up in file explorer

I started to learn git yesterday, and I made a mistake when I created ssh key as the first image shows.
I tried .bat delete way and dos del command, still cannot delete file named cd ..
The prompt said cannot find file. The attribute of file size is 0 byte.
How to delete this file?
I managed to delete "cd .." in a CMD Windows with <path/to/git>\latest\usr\bin in %PATH%. That gives me access to rm.exe.
vonc#VONCAVN7 C:\test
> where rm
D:\prgs\git\latest\usr\bin\rm.exe
I had:
vonc#VONCAVN7 C:\test
> dir /x
Volume in drive C is test
Directory of C:\test
08/08/2017 07:11 <DIR> .
08/08/2017 07:11 <DIR> ..
08/08/2017 07:11 0 cd ..
With that, I typed:
vonc#VONCAVN7 C:\test
> rm cd*
And the file cd .. was gone
As commented by eryksun,
rm.exe isn't a Linux app. It uses msys-2.0.dll, which links with Windows API functions from kernel32.dll and native NT system calls from ntdll.dll.
In this case it's how it bypasses the Windows API to make direct system calls that solves the problem: NtOpenFile (open the directory to list it and the "cd .." file to delete it), NtQueryDirectoryFile (list the directory), and NtSetInformationFile (set the file's delete disposition).
As eryksun commented, the pure Windows syntax (meaning, it does not need a Git Linux-like command like rm) would have worked too:
del "\\?\C:\test\cd .."
See "What does \\?\ mean when prepended to a file path".
That will disable all string parsing and send the string that follows it straight to the file system.
Look into the properties of the file. There you may find file location. Go to that location and delete from there.
And see which type of file is it. I mean, it may be a system file, and if it is, system will not allow you to delete it. Open explorer as administrator and then try deleting it.

Issue with win cmd finding folders

I am having an issue with the windows cmd line. When I cd into my Users dir my user folder shows as there but I cannot cd into. The path cd\Users\gmenfan83\ is my desired location. However, when I am in the Users dir and cd\Users\gmenfan83 \ I get a "The path is not found or specified" . I am more of a nix user but if the folder shows in the directory tree shouldn't I be able to cd into it? Thank you
Are you trying to use cd/Users/gmenfan83 while you have already used cd/Users? In that case you will not be able to find the file since you are already in the Users folder. Typing cd \Users\gmenfan83 right after opening cmd with C drive path should get you there.
It's unclear (even after your edit) what specifically you're doing, but this should get you started.
If you're currently in C:\users, and you want to change into the C:\Users\gmenfan83 folder, all you need is cd gmenfan83. If you're in C:\, all you need is cd users\gmenfan83.
Relative paths also work in Windows cmd.exe just as they do under *nix. To change from C:\users\gmenfan83\test to C:\users\gmenfan83\temp, you can use cd ..\temp, or specify cd \users\gmenfan83\temp.

Git Bash for Windows showing/expecting file paths with forward-slashes, no drive colon

I installed Git Extensions which automatically downloaded and installed Git for Windows, and when I use Git Bash, it shows the file path as /c/whatever/folder rather than C:\whatever\folder, and if I paste in a path from Windows Explorer, it chokes on it because it's expecting forward-slashes and no colon after the drive letter.
When I installed Git for Windows by itself previously, it showed the slashes/colon properly, but was much more limiting and harder to use (especially with copy/paste).
Why is it showing/expecting file paths with slashes and no colon, and how do I fix it?!
http://imgur.com/vMc7fU6
You could also try adding single quotes in the directory path copied from Windows Explorer and pasted in the Terminal prompt (e.g. cd 'D:\Documents\Developer Tools & Docs'). It worked for me. Check out the solution posted in the following link:
Escaping backslash in windows paths passed to unix programs
It's getting tripped up because the \ is an escape character in the Unix/Linux world. If the path you paste is like c:\\somefolder\\anotherfolder, it would be ok, because \\ says "I want a literal \. That said, my git bash understands a single \ as long as the path does not end with it. So cd c:\folder works, but cd c:\folder\ does not work.
BTW what error message is it giving you when it chokes, and can you give an example of a pasted path it chokes on.
This is caused by the Git Bash (Ming) shell, not because of anything git itself is doing.
If you run the mount command inside this shell, you will find that /c/ is the folder where your hard drive is mounted. If you want Git Bash to use a different folder name for your hard disk, you can map your disk to a different folder.
By the way, you shouldn't have to care about this when using git. Repos typically don't (and typically shouldn't) contain files in the root directory of a volume. Even if they did, git references files relative to the repository root. Since any folder that is the root level of a volume will also be the root level of any repo it's in, it will be called / in git, regardless of how the underlying operating system or shell labels it.
For your convenience, here is the output of mount from inside Git Bash on my laptop. You should get similar results. You can see that it indicates that C:\ is mounted on the /c folder.
chris#caerdydd MINGW64 ~
$ mount
C:/Program Files/Git on / type ntfs (binary,noacl,auto)
C:/Program Files/Git/usr/bin on /bin type ntfs (binary,noacl,auto)
C:/Users/chris/AppData/Local/Temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)

Using mklink command with network drives

I have two network drives that I access through Windows 7: V:\ and T:\ I am trying to create shortcuts between the two that alphabetise with folders (rather than files), so I am using the mklink command:
mklink /d \Photos V:\Photos
which creates a symlink at C:\.
I can move the symlink around locally. However, when I try to move the symlink to a network location, it begins copy the actual files over rather than symlinking them.
I figure that if I can create a symlink of a network drive on a local drive, what's stopping me creating a symlink of a network drive on another network drive. Am I correct in assuming this?
Is there any way to designate the destination file path when creating symlinks with the mklink command? Or is there any way to move symlinks to a network drive at all?
If you need to make a directory junction (using /J) on a network drive, you can first creation a directory (/D) symbolic link and then create a junction off of that, like so:
mklink /D D:\shareLink \\network\share
mklink /J D:\junctionLink D:\shareLink
You need to enable local to remote links by running this command with elevated rights:
fsutil behavior set SymlinkEvaluation L2R:1
Also you can enable this with your local or group policy:
Computer\System\Filesystem\Selectively allow the evaluation of a symbolic link --> allow local to remote
You will need to log onto the computer hosting the network drive and run the mklink command from there.
I recommend creating a junction /J instead of a symlinkd /D. Symlinks have some additional settings you need to be aware of. See symbolic-link-cannot-be-followed.

Resources