- pwd - show current directory.
- ls - show list of files and folders in the current directory.
- cd [directory] - move to specified folder.
- cd .. - move to parent folder.
- cd ~ - move to home directory.
- cd / - move to root directory.
- touch [filename] - create file with specified name.
- touch [filename_1] [filename_2] ... - create few files with specified names.
- mkdir [foldername] - create directory ith specified name.
- cp [filename] [directory] - copy specified file to a specified directory.
- mv [filename] [directory] - move specified file to a specified directory.
- cat [filename] - read text file content.
- rm [filename] - remove specified file.
- rmdir [folder-name] - remove specified directory.
- rm -r [directory] - remove specified directory and all nested files and directories.
- You do not have to type and execute commands in turn.
You can specify them by a list - divide by two ampersands (&&). - The console has its own memory - a buffer with the last few commands.
They can be moved with up and down arrow keys. - To avoid typing the name of a file or folder completely,
you can type the first name characters and double-click Tab.
If the file or folder is in the current directory,
the command line will add the path itself.
- git init - initialise a repository.
- git remote add origin [remote-repo-url] - bind a local repository to a remote one with specified URL.
- git remote -v - check if repos was really binded.
- git push -u origin main - at first time, upload all the commits from a local repository to a remote one.
- git push - upload commits to a remoted repository after it was binded with -u flag.
- git add [filename]- prepare specified file for commit.
- git add --all - prepare all the new and modified files for commit.
- git add . - prepare a current folder and all nested files for commit.
- git commit -m "[message]" - make a commit and leave a commentary for easier understanding of what changes was made.
- git push - add changes to remote repository.
- git log - show detailed commit history.
- git log --oneline - show brief information about commits: shortened hash and the message.
- git status - show currrent repository state.
- git commit --amend --no-edit - add changes to a last commit and keep message the same.
- git commit --amend -m "[message]" - replace message for a last commit with new [message].
- git restore --staged [filename]- change specified file from staged state to untracked or modified state.
- git restore [filename] - return file to its last version that was saved via git commit or git add.
- git reset --hard [commit-hash]- remove all the changes from workzone and staging zone and rollback them to a specified commit.
- git diff - show the difference between modified files and last saved files.
- git diff [commit-hash-1] [commit-hash-2] - show the difference between two commits.
- git diff --staged - show the changes in staged files.
- git clone [remote-repo-url] - clone specified remote repository on local machine.
- git branch [branch-name] - create a new branch called [branch-name] from the current.
- git checkout -b [branch-name] - create a new branch called [branch-name] and switch to it.
- git branch - show available branches in a current repository.
- git checkout [branch-name] - switch to a specified branch.
- git diff main HEAD - show the difference between main branch and pointer to HEAD.
- git diff HEAD~2 HEAD - sow the difference between the commit that was two commits ago and the current one.
- git branch -d [branch-name] - remove specified branch but only if it's part of the main branch.
- git branch -D [branch-name] - remove specified branch even if it's not the part of the main branch.
- git merge [branch-name] - merge specified branch with current active branch.
- git push -u origin [branch-name] - push new branch to a remote repository and bind a local branch with a remote one, so for further commits and puashes you could use the command without -u.
- git push [branch-name] - push aadditional changes to a specified branch, which is already exists in a remote repository.
- git pull - download changes for a current branch from a remote repository.