Description | Command |
---|---|
Current Directory | . (single period) |
Parent Directory | .. (double period) |
Home Directory | ~ (tilde ) |
Make a new directory | mkdir <directoryname> |
Delete a directory (only works on empty folders) | rmdir <foldername> |
Delete a directory and its contents | rm -R -f <foldername> |
Make a new file | touch <file1.ext> |
Delete a file (This deletes the file permanently; use with caution.) | rm <file1.ext> |
Delete a file ONLY when you give confirmation | rm -i <file1.ext> |
Delete a file by FORCE without confirmation | rm -f <file1.ext> |
Delete multiple files without confirmation | rm <file1.ext> <file2.ext> <file3.ext> |
Move/Rename a file | mv <file> <newFileName> |
Move a file to the folder, possibly overwriting an existing file | mv <file> <foldername> |
Copy a file to a folder | cp <file> <foldername> |
Copy/Duplicate a file in the same directory | cp <file> <newFileName> |
Description | Command |
---|---|
We use it to navigate and change directories | cd |
Print (current) working directory | pwd |
Change directory, e.g. cd Documents | cd [folder_name] |
Root Directory | cd ~ |
Previous directory or folder you last browsed | cd - |
Move up to the parent directory | cd .. |
Move up two levels | cd ../.. |
MAC Users: Open a finder window at current location | open . |
WINDOWS: Open a File Explorer at the current location | start . |
Open a URL | open http://www.google.com |
Open a file in your default text editor | open -e <filename> |
Description | Command |
---|---|
list files in the current directory | ls |
list will show size, modified date and time, permissions. | ls -l |
list all files including hidden files starting with ‘.‘ | ls -a |
list shows sizes in human readable format | ls -lh |
list files and directories in reverse order | ls -lr |
list will display very long listing directory trees | ls -R |
list will show latest modified file or directory date as last | ls -ltr |
list file size in order, will display big in size first | ls -lS |
output the contents of a file | cat <filename> |
list all running processes | ps |
terminate existing process | kill <process> |
Cloning repo to your local computer
git clone <ssh-url>
git pull
Push branch to remote git push origin <branch>
Sync local branch with remote git push -u origin <new-branch>
Create and Switch to new local branch git checkout -b <new-branch>
Checkout a particular branch git checkout <branch>
Deletes local branch git branch -d <branchname>
git reset --soft HEAD-1
Reset will rewind your current HEAD branch to the specified revision. In our example above, we'd like to return to the one before the current revision - effectively making our last commit undone.
Note the --soft flag: this makes sure that the changes in undone revisions are preserved. After running the command, you'll find the changes as uncommitted local modifications in your working copy.
If you don't want to keep these changes, simply use the --hard flag. Be sure to only do this when you're sure you don't need these changes anymore.
git reset --hard HEAD-1
git diff --stat HEAD
Show commit info, diffstat and patch, you can replace 'HEAD' with the hash belonging to the commit you would like to inspect.
git show HEAD
Long version
git log
Short oneline version
git log --oneline