Giter Site home page Giter Site logo

cheatsheet's Introduction

Console basics

Navigation

  • 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.

Working with files and folders

Creating

  • 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.

Copying and moving

  • cp [filename] [directory] - copy specified file to a specified directory.
  • mv [filename] [directory] - move specified file to a specified directory.

Reading

  • cat [filename] - read text file content.

Removing

  • rm [filename] - remove specified file.
  • rmdir [folder-name] - remove specified directory.
  • rm -r [directory] - remove specified directory and all nested files and directories.

Useful Features

  • 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 basics

Repository initialization

  • git init - initialise a repository.

Synchronizing local and remote repositories

  • 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.

Preparing file for a commit

  • 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.

Creating and publishing a 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.

Checking informtaion about commits

  • git log - show detailed commit history.
  • git log --oneline - show brief information about commits: shortened hash and the message.

Checking for files state

  • git status - show currrent repository state.

Adding changes to last commit

  • 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].

Rollback files and commits

  • 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.

Checking for changes

  • 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 branches

Cloning someone's els repository

  • git clone [remote-repo-url] - clone specified remote repository on local machine.

Branches creating

  • 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.

Navigating through branches

  • git branch - show available branches in a current repository.
  • git checkout [branch-name] - switch to a specified branch.

Branches comparing

  • 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.

Branches removing

  • 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.

Branches merging

  • git merge [branch-name] - merge specified branch with current active branch.

Working with remote repository

  • 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.

cheatsheet's People

Contributors

alsg00 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.