-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Welcome to the Python-101-2019 wiki!
As our teams will be using a unix environment application, via Git Bash, to interact with our github repository, we thought it would be helpful to include a quick cheatsheet to assist in the learning/refreshing of common commands we will be using.
If you have any questions, please feel free to reach out.
Git Bash : At its core, Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals.
Git : A distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files.
alias - create a command variable -
e.g. alias subl='ApplicationsFolder/TextEditorsFolder/Sublime.exe'
cat - display the contents (i.e. text) of a file -
e.g. cat FileWithText.txt
cd - change directory -
e.g. cd MainFolder/SubFolder/SubSubFolder
e.g. cd .. (this moves up to the previous folder)
e.g. cd ../../.. (this moves up to the 3 previous folders)
clear - clear the terminal view -
e.g. clear
cp - copy file or directory -
e.g. cp FileName.txt NewDirectory/FileName.txt
ls - list files & subdirectories -
e.g. ls (list files in current directory)
e.g. ls -a (list files in current directory including hidden files, .bashrc is a hidden file)
e.g. ls SpecificFolder/SpecificSubFolder (list files in specified directory)
mkdir - make directory
e.g. mkdir NewDirectoryName
mv - rename or move files or directories
e.g. mv CurrentDirectory/FileName.txt NewDirectory/FileName.txt
e.g. mv OldFileName.txt NewFileName.txt
pwd - display present work directory
e.g. pwd
rm - remove files or directories
e.g. rm MyFile
NOTE: When removing directories, if the directory is not empty this command will throw an error stating
the directory that you desire to remove contains data. If you still need wish to remove the directory
along with of its contents, simply add -rf to your command:
rm -rf MyDirectory
source - reads and executes the commands within a shell script
e.g. source .bashrc
NOTE: shell scripts are files that contain a series of unix commands that the user desires to be completed. This is usually done to set environments up and/or complete repetitive tasks quickly with one command, instead of executing each command one-by-one.
touch - create a new file
e.g. touch newfile.txt
vi - open text editor
e.g. vi FileToEdit.txt
NOTE The vi editor has a few commands within it, so if you choose to use this as a quick editor here are a few commands to operate within the vi editor:
* `i` must be clicked to begin inserting text in the file
* ESC button should be used when you're finished inserting text to exit insert mode
* `:q` quits the vi text editor
* `:q!` force quits the vi editor if you've made changes to the file but don't wish to save
* `:wq` quits the vi editor and saves all changes
* `/` followed by characters starts a search in your file for the characters that follow '/'
**NOTE:** You can iterate through multiple occurrences of the character/string you're
searching for by click 'n' during search
* `:` followed by a number takes you to a specific line number in the file
add - adds a file or multiple files to the git staging area
e.g. git add MyNewFile.txt
branch - gets list of branches in current repository or create branch
e.g. git branch (provides list of branches)
e.g. git branch MyNewBranch (creates new branch)
checkout - switches to a specific branch version of your repository
e.g. git checkout develop
clone - copies a repository (folders and their included files) to your machine (computer)
e.g. git clone https://github.com/NIAGroup/PyStockAnalyze-2019.git
commit - stores the current version of your new file(s) to your local repository (not to github)
e.g. git commit -all (commits everything in your staging area)
e.g. git commit -all -m "this is my commit message" (commits everything in your staging area)
e.g. git commit myNewFiles.txt -m "this is my commit message" (commits a specified file from your staging area)
NOTE: You cannot commit without adding first.
NOTE: You will be required to provide a comment for each commit attempt.
log - lists all the changes that have transpired in your local repository
e.g. git log
merge - merges branches
e.g. git merge new branch
pull - pulls all of the content of the current state of the github repository to your local copy of the repository
e.g. git pull
NOTE: If there are differences in files between github and your local directory, there will be error messages provided stating these files as conflicts of which you can resolve by different means.
push - pushed all of your committed files to the github repository (think of it as publishing for everyone to see/review)
e.g. git push
status - provides the status of your current local repository and how it differs with the github repository's current state
e.g.git status