These are the materials for my web development course at ECC for workforce development
Note Always try to use tab whenever possible, it saves on spelling errors and helps you move faster
pwd
: Print Working Directory tells you where in the filesystem you arecd
: change directorycd ../
will put you into the parent directory (up a level) from where you arecd ~
will put you into your home directorycd /some/file/path/to/some/directory
will put you in to the folder path you described
ls
: list directory contentsls -a
lists all contents including hidden filesls -l
lists all files and shows information about them such as modified date and sizels /
will show "normal" files in your root directory- combining all of these you could show all files in the root, and the data about them using
ls -la /
cp
: copycp -r /source/directory/name/ /destination/directory/
will copy the content of source to destinationcp file_1 new_file
will make a copy of file_1 named new_file
mv
: moves and renames files and directoriesmv directory1/ /some/other/directory/location/
will move the directory into the destination providedmv file_name newFileName
will rename file_name to newFileName
find
: find files and directoriesfind /tmp -type f -empty -delete
will find all empty files in the/tmp
dir and delete them
Note: You have to be in a git repository (directory) to use git commands
git status
: shows you the current status including branch and file statusgit checkout branch-name
: will check you out to a branch called branch-namegit checkout -b branch-name
: will create and check you out to a branch called branch-namegit add filename
: will stage the changes in filename to be committedgit add .
: will stage the changes in all files to be committedgit commit -am "this is where you message goes"
: will stage and commit all files that are currently tracked by gitgit branch --merged <main-branch-name> | grep -v '<main-branch-name>$' | xargs git branch -d
this allows you to safely delete all branches that have been merged into what ever branch you supply as<main-branch-name>
; see the example below.- NOTE: I recommend adding this as an alias (
vim ~/.bashrc
or whereever you keep aliases) in the form ofalias pruneBranches='git branch --merged "$1" | grep -v "^$1$" | xargs git branch -d'
. You can then call it withpruneBranches main
. This is safe for almost any git setup whether its GitHub, Bitbucket, GitLab or any others.
- NOTE: I recommend adding this as an alias (
git clone url
cd <repository name>
git checkout -b <name-of-branch>
- create and update some files
git status
git add <filename(s)>
git commit -m "the message that identifies what changes were made"
git push -u origin <name-of-branch>
- at this point you can continue editing code and making commits and pushing those commits by repeating steps 2-5 and running
git push
without the -u argument - create a pull request
- add a reviewer to the pull request
- assign yourself to the pull request
- once approved merge the request into main/master
git checkout main/master
git pull -p
git checkout <master-branch-name>
git pull -p
git checkout <feature/bugfix branch>
git merge <master branch name>
- resolve conflicts
git add <filename(s) of fixed file(s)>
git merge --continue
git push