commands to cover:
ls
- list files in current directorycd
- move to a specific directory.cd ..
- move to parent directoryexplorer.exe .
- opens file explorer in current directorycode .
- opens the best code editor in current directory
-
git clone
- download all files from a specific repositorium -
git init
- creates a new git repository in current directory -
git add filename.txt
- similar to putting some items (changes) into a box. It's easy to get them out, and they are all in one place.git add .
- generally considered bad practice (but you will start doing it anyway). Adds all changes you made in repository.
-
git status
- lists files on staging area -
git commit -m "text"
- equivalent of sealing the package an putting it into a post box. A bit harder to revert, package has date and name on it. Usually used with-m
flag to quickly add commit message. -
git push
- comparable to postman taking your package somwhere. Pretty hard to cancel, package is in a remote location.git push -f
- force push. Overwrites data on remote with yours. Usefull when you want to remove commits from a remote. Use with caution.
-
git pull
- a bit like getting a delivery. git pull tries to automatically merge your changes with remotegit fetch
- sub-command of git pull. Downloads changes, but does not merge them.
-
git reset
HEAD^
- allows you to delete last commitHEAD~2
- allows you to delete last two commits--hard
- removes changes completely--soft
- removes commit, and moves changes back to staging area
-
git stash
- similar to a commit, but it should exist only temporarly. -
git checkout
- allows you to peek at a particular commit, or change branchgit switch
- allows you to change branch
-
git log
- shows you info about last commitsgit log --oneline
- more brief info- vim - to exit press :q
git log --oneline --graph
- shows you a graph of commits. usefull on more complex repositioriesgit log --graph --pretty=oneline --abbrev-commit
- same but prettier
-
git branch
- lists all local branches of your repositorygit branch new
git branch -a
- lists all branches (remote included)
-
git rebase
- preffered over merge. "Uproots" branch you are currently on, and attaches it to specified other branch/commitgit rebase -i
- interactive rebase. Allows you to change commits before they are applied to the branch you are rebasing on. Very powerfull and versatile, detailed instruction appears after running the command
-
git merge
- unifies two distinct timelines -
git revert
- creates a new commit that reverts changes from a specified commit (it adds another commit, cancelling changes from previous, but does not delete it's predacessor)
-
pull requests - (also known as pr) this is a github way of asking administration of a project to merge your changes into main branch. Typicaly, changes are reviewed by someone (other than author) to double check for any unwanted happenings. Additional checks may be also added using github actions (e.g. running unit tests evry commit, linter checks)
-
.gitignore
- is a file that allows you to specify what git should avoid. E.g: It's a good practice to not commit your executables, and other files generated during runtime -
.md files
- can be used as a detailed description of your project.README.md
(like this file) will be displayed on the front page of your repository. Markdown is widely supported and very simple in syntax, making it excellent for documentation -
forking - it's a way to copy a repository. Very similar to branching, but on a repository scale
-
merge conflicts - when file is modified in both timelines, It cannot be merged automatically, and merge conflicts occur. It is required that someone manually decides which changes to keep or rewrites entire file. Vscode provides decent merge editor, which is suggested at every merge conflict. It uses technique called 3-way merge. 3-way because you see both changes A, changes B, and oryginal file.