Where did I move my file to? (mv in git bash) - terminal

I'm using Git Bash on Windows and just moving my files around locally. Here's my folder path:
/e/Python/Python---CS-170/CS170_homework/
I tried to move my files from Python---CS-170 to the sub folder CS170_homework and it a bit of curiousity, I typed this:
mv Python---CS-170/CS170_homework /
Now all the content in the folder Python---CS-170 is moved somewhere. Can you tell me where the files are moved to? I know the place it went to is "/", but what does it mean?

Can you try running on the Git Bash these commands:
cygpath -w /
On my system I am getting output as:
C:\Program Files\Git\
You can navigate to the folder using explorer to find the files you are looking for.
Here is the documentation for the utility.

Related

How to run a .sh script to create a *.zip file?

I try to write a shell script create_zip.sh to zip my desired folders as a .zip file.
The content of create_zip.sh is as following:
CODE_DIR='exercise_code/'
EXERCISE_ZIP_NAME='exercise_01.zip'
EXERCISE_DIR=$(pwd)
echo 'Zipping file '$EXERCISE_ZIP_NAME
zip -r $EXERCISE_ZIP_NAME $CODE_DIR
echo $EXERCISE_ZIP_NAME ' created successfully!!! '
But when I double-clicked on the file create_zip.sh, it just opened the Git Bash window and closed immediately. Then nothing happened! (No output message, no newly created *.zip)
How can I solve it? I am using Win10 and with Git Bash as default application to open *.sh file.
Any solution will be very appreciated.
You probably don't have zip installed in Git Bash.
Try the following steps:
Navigate to https://sourceforge.net/projects/gnuwin32/files/zip/3.0/
Download zip-3.0-bin.zip
In the zipped file, in the bin folder, find
the file zip.exe
Extract the file "zip.exe" to your "mingw64" bin
folder (for me: C:\Program Files\Git\mingw64\bin)
Navigate to https://sourceforge.net/projects/gnuwin32/files/bzip2/1.0.5/
Download bzip2-1.0.5-bin.zip
In the zipped file, in the bin folder, find the file bzip2.dll
Extract bzip2.dll to your "mingw64" bin folder (same folder - C:\Program Files\Git\mingw64\bin)

Windows 10 and WSL - Directories not appearing in Bash when created in File Explorer

Using Windows 10 Enterprise Insider Preview Buil 14372.rs1_release.160620-2342
When I create a directory in Bash (e.g. mkdir test_from_bash) it appears in the File Explorer but the opposite doesn't work. File Explorer -> New Folder (call it 'test_from_gui') then running ls -al in Bash does not show the new directory.
I don't think this is a permissions problem since I went into the Properties -> Security section for each directory using the File Explorer and both of the aforementioned directories both have every box checked except for 'Special permissions' at the bottom of the list.
Result from ls -al:
File explorer:
Is this a bug?
Workaround -
Create and work out of directories that are outside of the Ubuntu 'container', you can find them in the /mnt directory. For example, you can happily read/write/modify/delete files from C:\Users in Windows Explorer (or cmd or anywhere else in Windows land) and also do the same from Bash but those files will be located in /mnt/c/Users. Not perfect, though, and I'd love to see a better answer.

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)

Why won't cygwin read the .ssh/config file in my home directory?

I am using cygwin and I am trying to set up an .ssh/config file. Cygwin's folder is in my C: drive. My Home directory is C:\Users\USER. I have noticed that when I edit C:\Users\USER.ssh\config, cygwin does not even notice it (even though it notices the other files I have in my USER folder, i.e. .bashrc). But it does notice the config file if I put it in C:\cygwin64\home\USER.ssh\config.
Is there a way to get cygwin to read the .ssh folder in my USER home directory instead?
Make sure your home directory setup in /etc/passwd matches /home/ Often it is not set at all (second to last field in the ':' delimited line. Then you'll need to restart your cygwin session (exit the terminal, and restart)
That should fix your problem.
This isn't the greatest solution but it works:
ln -s /cygdrive/c/Users/username/.ssh /home/username/.ssh
If /home/username/.ssh already exists, perhaps rename it to .ssh_original or move the files into the other .ssh folder.

Why are files created in git bash not visible in Windows explorer?

So I just moved from Ubuntu to Windows (read forced to move, thanks to compatibility issues) and am using Git Bash to pull in my files. I've noticed something extremely strange.
Git Bash is installed in C:\Program Files (x86)\Git\, and when I first run the Git Bash program, the default location is this. Normal right? Right.
But here's the weird part..
When I run the command mkdir srv in the Git Bash command line, I can see it in the Bash window - but I can't see it in Windows Explorer?! What the heck. Same thing happens with files created using vi in the CLI. Invisible in Windows Explorer. (Yes, I have enabled the Show hidden files option in Explorer, so it's not that).
Here are some snapshots (no, I'm not blind - nor am I insane). Help?
You might not be able to see the folder because of missing privileges. Try running your explorer as Administrator and look again.
The proposed solutions above didn't help me. However, I copied the hidden directories to another place via git bash. Then I copied them once again via windows explorer to the original place. Now they've become visible. I created those invisible folders via git bash with git clone command before.
I had similar issue, but with file attributes, not with missing privileges.
In cmd under C:\Program Files (x86)\Git\ run command attrib
attrib *
You will know if srv folder has System or Hidden file attribute.
If you would like to view it in cmd then use dir /a:s

Resources