Get out of a folder using Git Bash - windows

I am using Git Bash and am trying a few things like making a 'commit' and 'push' to GitHub.
I want to get out of the current directory C:\user\myUsername\app and land in the C:\user\myUsername folder.
What commands do I write in Git Bash?

To change your directory in git-bash to that specific path you can use this command :
cd /c/user/myUsername
basically you have to replace backslash with standard slash, or otherwise if you simply want to go to the parent directory you can use :
cd ..
as stated in comments that you already received on your question ...

Just wanted to add, make sure to insert space between cd and ..
no: cd..
yes: cd ..

If you want to move one directory up, just type command cd .. if you are following any tutorials most probably they will use macOS so that means they will use there own linux commands like
cd/home/your username.So just click type cd .. it will leads to go to previous directory.Most probably people will type like this cd ..users/username so don't do that mistake; just type cd .. .
Other mistakes:
don't type :- cd..
do :- cd ..
give space between cd and dots.

If you want to quickly move one directory up in git bash, type the command cd ../ and make sure there is a SPACE between cd and .. My version of Gitbash will NOT do anything if I type cd .. ONLY.

You can also use this command in git-bash to go back to the previous directory :
cd -
The above command does the same as cd ..

Related

having trouble with cd and getting back to a directory

For school, I have to switch between my top level directory which is git-basics-lab-online-web-sp-000 back to the sub directory I made which is called my-repository.
I was switching back and forth no problem using {cd} but when I tried to switch back to my-repository using
cd my-repository
my terminal is now saying
bash: cd: my-repository: No such file or directory
what did I do wrong?! How come it worked before but now it's giving me this message?
Perhaps we are missing more information. That is, if you moved correctly from one directory to another, there is no reason why it should disappear just like that.
Besides cd, there are other commands that will help you to know which directory you are in, and where you can go. I summarize them below:
Show the full path to the current directory:
pwd
List files and folders (except hidden ones):
ls
Enter the dir directory (assuming it exists where we are):
cd dir
Exit dir (see edit):
cd ..
Obviously each command has a number of options that increase its functionality. You can always access them with the man command (for example, man cd will show you the cd command help).
That is, once the terminal showed you the error you mention, you can run ls to verify, for example, if you typed the folder name wrong. Then you can also try pwd to confirm that you are where you think you are. And finally you can move with cd to where you think you are.
EDIT: As suggested by Roadowl, cd - and cd .. are not strictly the same thing (in the example I assume we go one directory at a time).
I will try to illustrate this with an example to show the difference.
Suppose we have the dirc folder inside dirb and this, in turn, inside dira ( dira/dirb/dirc ). Let us also suppose that we are in dira. To enter directly to dirc we would have to execute cd dirb/dirc. And this is where the difference is illustrated:
If we run cd .. we are going to be positioned in dirb.
If we run cd - we will go back to the dira directory we were in before running the command.
This error message simply means that the directory/file you specified could not be found at your current location. If you look to the left of where you are typing, your current directory should be displayed, something like /you/are/here/ >
You can type cd .. to navigate up one level (towards the root directory).
If you are sure the directory exists you are trying to cd into, then you probably just aren't currently in the right location, and you need to either cd .. or cd somewhereelse until you get there.

problems with git bash on windows. i can't access folders on git bash for windows

i bought a course from codecademy and at beginner was a lesson about git bash. I install it , but if i want to change directories with "cd" i cant't.
enter image description here
Also , when i double-click on shortcut the program doesn't run.
Try changing to you home directory first
$ cd
then
$ pwd
/c/Users/yourname
Try going to you root directory with : cd / (make sure you add a space between cd and /)
Then do cd yourfilename/yourfilename....you can add multiple directories
Make sure your spelling is correct
Few other tips :
To navigate to your home directory use "cd ~".
To navigate to the previous directory use "cd -"

purpose of chdir with a single dot (cd .)

This might appear a noob question.
While working in bash, if we run cd ., it stays in the current folder.
I understand the functionality, however, I am not able to understand the rationale of this functionality?
What would be some practical ways to use this?
The primary use case I've seen for cd . is to test whether your file handle on the current directory is still valid.
If you're on a directory from a network share -- NFS, or the like -- it can be possible for directories to be remotely deleted, but for the local client to still believe they're accessible and in use.
cd . is a way to trigger an error if your handle on the current working directory is no longer valid.
This is the only "practical" case that came to my mind
$ cd .
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
when your process has a current working directory referencing a directory that has been removed by another process.
That command has no functionality. But in a POSIX-compliant environment, if you add a -P option, then it has functionality: it resolves symlinks. So for example on a Mac, if you cd to a path with a symlink:
cd /System/Library/Frameworks/AppKit.framework/Versions/Current
...then do cd -P . ... you will point to:
/System/Library/Frameworks/AppKit.framework/Versions/C
. is a special file that represents the current directory.
There are plenty of things which make use of directories and it is sometimes useful to refer to the current directory.
Changing the directory to the current directory is not one of those.
A simple example where cd . fails:
mkdir my_error
cd my_error
rm -rf ../my_error
cd .
When the rm is embedded in a difficult script or can be done by some other cleanup process, is can be an useful check.
I use a build script which removes and recreates a directory.
The old directory disappears and new appears with new inode.
If, in one of my shells my $PWD is that reappeared directory and I notice
it became unusable (and I know it was recreated), I just
$ cd .
to get the (new) directory useable again and can continue my work there.

How to change directory under git bash

Could you tell me please how to change directory using git bash?
Exactly I want go to C:/Program Files
I type cd c:/ - move to c:/.
I type cd Program Files and I get message that "there is no such directory Program".
So the problem is how to go to the directory name of which consists of two words that are separated by whitespaces.
I'm using Windows 7 operating system.
cd gets just one argument, so if you say cd Program Files it does cd Program. So you need to quote Program Files if you want cd to it as just one argument:
cd "Program Files"
otherwise it is trying to find the directory Program.
You could also type the space as escape seqence:
cd /c/Program\ Files/Git/
Please find below to add windows path in git bash or in unix
export PATH=$PATH:/c/Program\ Files/Java/jdk1.8.0_221/bin:/c/Program\ Files/apache-maven-3.6.1/bin

How do I reverse the cd command in the Terminal on Mac OS X?

I am beginning to learn ruby and was following the instructions of one video to access the desktop through the -ls command in the terminal. Now, I would like to get out of the desktop in the terminal and don't know how. I know, I know I am a total noob... but can someone please help. Thanks. BTW the command I wrote was:
my-iMac~ me$ cd Desktop/
my-iMac:Desktop samuel$ ls
Where would you like to go?
Go home: cd or cd ~
Go to the previous working directory: cd $OLDPWD
Go to parent of the current directory: cd ..
Go to any directory you want: cd /path/to/directory
cd .. will take you back up 1 level.
for windows, you can open up the file explorer copy path then in your command prompt type "cd" then paste path. Your command prompt should now default to that path. (you can also type the entire path)
cd C:\Users\username\Documents\Folder

Resources