Developer Cheat Sheets
git config --global user.name "[name]"
git config --global user.name "[name]"Description: Set your username globally for all repositories.
Scenario: First-time Git setup on a new machine.
Example:
git config --global user.name "Your Name"git config --global user.email "[email]"
git config --global user.email "[email]"Description: Set your email globally for all repositories.
Scenario: First-time Git setup on a new machine.
Example:
git config --global user.email "youremail@example.com"git config --list
git config --listDescription: List all Git configurations.
Scenario: Verifying current Git settings.
Example:
git config --listgit init
git initDescription: Initialize a new Git repository.
Scenario: Starting a new project from scratch.
Example:
git init my-projectgit clone [url]
git clone [url]Description: Clone an existing repository.
Scenario: Getting a copy of an existing project.
Example:
git clone https://github.com/user/repo.gitgit status
git statusDescription: Show the working tree status.
Scenario: Checking what changes are ready to be committed.
Example:
git statusgit add [file]
git add [file]Description: Add file contents to the staging area.
Scenario: Preparing a specific file for commit.
Example:
git add index.htmlgit commit -m "[message]"
git commit -m "[message]"Description: Record changes with a descriptive message.
Scenario: Saving your staged changes.
Example:
git commit -m "Add initial project structure"git push origin [branch]
git push origin [branch]Description: Upload local repository content to remote.
Scenario: Sharing your commits with the remote repository.
Example:
git push origin maingit pull origin [branch]
git pull origin [branch]Description: Fetch and merge changes from remote.
Scenario: Updating your local branch with remote changes.
Example:
git pull origin maingit branch
git branchDescription: List all local branches.
Scenario: Seeing available branches.
Example:
git branchgit branch [branch-name]
git branch [branch-name]Description: Create a new branch.
Scenario: Starting work on a new feature.
Example:
git branch feature-xgit checkout [branch]
git checkout [branch]Description: Switch to an existing branch.
Scenario: Changing to a different branch.
Example:
git checkout developgit checkout -b [branch]
git checkout -b [branch]Description: Create and switch to a new branch.
Scenario: Creating and starting work on a new branch.
Example:
git checkout -b hotfix-123git merge [branch]
git merge [branch]Description: Merge the specified branch into current branch.
Scenario: Integrating changes from one branch into another.
Example:
git merge feature-xdocker images
docker imagesDescription: List all local images.
Scenario: Checking available Docker images on your system.
Example:
docker imagesdocker pull [image]
docker pull [image]Description: Download an image from registry.
Scenario: Getting a new Docker image.
Example:
docker pull ubuntu:latestdocker build -t [name] .
docker build -t [name] .Description: Build an image from Dockerfile.
Scenario: Creating a custom Docker image.
Example:
docker build -t myapp:v1 .docker rmi [image]
docker rmi [image]Description: Remove one or more images.
Scenario: Cleaning up unused images.
Example:
docker rmi myapp:v1docker ps
docker psDescription: List running containers.
Scenario: Checking active containers.
Example:
docker psdocker run [image]
docker run [image]Description: Create and start a new container.
Scenario: Running an application in a container.
Example:
docker run -d -p 8080:80 nginxdocker stop [container]
docker stop [container]Description: Stop one or more running containers.
Scenario: Gracefully stopping a container.
Example:
docker stop my_containerdocker exec -it [container] [command]
docker exec -it [container] [command]Description: Run a command in a running container.
Scenario: Accessing a shell inside a container.
Example:
docker exec -it my_container bashls -la
ls -laDescription: List directory contents with details.
Scenario: Viewing files and directories with permissions.
Example:
ls -la /var/logcd [directory]
cd [directory]Description: Change current directory.
Scenario: Navigating the file system.
Example:
cd /var/logmkdir [directory]
mkdir [directory]Description: Create a new directory.
Scenario: Creating a new folder.
Example:
mkdir new_projectrm [file]
rm [file]Description: Remove files.
Scenario: Deleting a file.
Example:
rm temp.txtcp [source] [dest]
cp [source] [dest]Description: Copy files or directories.
Scenario: Making a copy of a file.
Example:
cp file.txt backup/mv [source] [dest]
mv [source] [dest]Description: Move or rename files.
Scenario: Renaming or moving a file.
Example:
mv old.txt new.txtcat [file]
cat [file]Description: Display file content.
Scenario: Viewing the content of a file.
Example:
cat error.loggrep "[pattern]" [file]
grep "[pattern]" [file]Description: Search for patterns in files.
Scenario: Finding specific text in a file.
Example:
grep -i "error" server.loghead [file]
head [file]Description: Show first lines of a file.
Scenario: Viewing the beginning of a large file.
Example:
head -n 20 access.logtail [file]
tail [file]Description: Show last lines of a file.
Scenario: Monitoring log files in real-time.
Example:
tail -f app.logarray.map(callback)
array.map(callback)Description: Transform each element in an array.
Scenario: Converting an array of numbers to their doubles.
Example:
const doubled = numbers.map(n => n * 2)array.filter(callback)
array.filter(callback)Description: Create a new array with filtered elements.
Scenario: Getting only even numbers from an array.
Example:
const evens = numbers.filter(n => n % 2 === 0)array.reduce(callback, initial)
array.reduce(callback, initial)Description: Reduce array to a single value.
Scenario: Calculating the sum of all numbers.
Example:
const sum = numbers.reduce((acc, n) => acc + n, 0)array.find(callback)
array.find(callback)Description: Find the first element that matches condition.
Scenario: Finding a specific user by ID.
Example:
const found = users.find(user => user.id === 1)const { prop } = object
const { prop } = objectDescription: Destructure properties from objects.
Scenario: Extracting specific properties from an object.
Example:
const { name, age } = userconst [first, ...rest] = array
const [first, ...rest] = arrayDescription: Destructure arrays with spread operator.
Scenario: Getting the first element and the rest separately.
Example:
const "color: #fbbf24;">[head, ...tail] = "color: #fbbf24;">[1, 2, 3, 4]async function name() {}
async function name() {}Description: Define an asynchronous function.
Scenario: Making asynchronous API calls.
Example:
async function fetchData() { return await api.get('/data') }const result = await promise
const result = await promiseDescription: Wait for a promise to resolve.
Scenario: Waiting for an API response.
Example:
const data = await fetch('/api/users')