Git Commands Cheat Sheet 2026 — Every Command You Need

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers Git commands from basics to advanced workflows. Last updated: April 2026 Setup and Config Command Description git config --global user.name "Alex" Set your name (shown in commits) git config --global user.email "alex@example.com" Set your email git config --global init.defaultBranch main Set default branch name git config --list Show all config settings git init Create a new repository git clone <url> Clone a remote repository git clone <url> <folder> Clone into a specific folder Basic Workflow Command Description git status Show changed, staged, and untracked files git add <file> Stage a file for commit git add . Stage all changes git add -p Stage changes interactively (hunk by hunk) git commit -m "message" Commit staged changes git commit -am "message" Stage tracked files and commit (does NOT stage untracked files) git commit --amend Modify the last commit (add files or fix message) git diff Show unstaged changes git diff --staged Show staged changes (ready to commit) git diff HEAD Show all changes (staged + unstaged) Working Directory → git add → Staging Area → git commit → Repository Viewing History Command Description git log Show commit history git log --oneline One line per commit git log --oneline --graph --all Visual branch graph git log -5 Show last 5 commits git log --author="Alex" Filter by author git log --since="2026-01-01" Commits after a date git log -- <file> History of a specific file git show <commit> Show details of a commit git blame <file> Show who changed each line Branching Command Description git branch List local branches git branch -a List all branches (local + remote) git branch <name> Create a new branch git branch -d <name> Delete a branch (safe — won’t delete unmerged) git branch -D <name> Force delete a branch git branch -m <old> <new> Rename a branch git switch <name> Switch to a branch git switch -c <name> Create and switch to a new branch git checkout <name> Switch to a branch (older syntax) git checkout -b <name> Create and switch (older syntax) Branch Workflow (ASCII Diagram) main: A --- B --- C --- F (merge commit) \ / feature: D --- E - Merging Command Description git merge <branch> Merge branch into current branch git merge --no-ff <branch> Force a merge commit (no fast-forward) git merge --squash <branch> Merge all commits as one (does not auto-commit) git merge --abort Cancel a merge in progress Resolving Conflicts When Git cannot auto-merge, it marks conflicts in the file: ...

March 17, 2026 · 6 min

Jetpack Compose Tutorial #5: State — The Most Important Concept

This is the most important tutorial in the entire series. If you don’t understand state, nothing in Compose will make sense. If you do understand it, everything clicks. State is the reason the login form from the previous tutorial worked. It is the reason buttons can toggle, text fields can update, and screens can change. Without state, your UI is frozen — it shows something once and never changes. Let’s fix that. ...

March 17, 2026 · 10 min

How to Build Your First AI Coding Agent (Step by Step)

In the previous article, we learned what AI coding agents are. Now let’s build one. Not a toy demo. A real agent that reads your code, finds problems, fixes them, runs tests, and commits the result. You will understand how agents work from the inside. We will use Python and the Anthropic SDK (Claude API). The concepts apply to any AI provider. What We Are Building A simple agent that: Reads a Python file Sends it to Claude with instructions to fix linting errors Writes the fixed code back to the file Runs the linter to verify the fix If it still fails — tries again (up to 3 attempts) Commits the result with git This is the same loop that Claude Code and Copilot Agent use internally — just smaller and simpler. ...

March 16, 2026 · 8 min

Kotlin Cheat Sheet 2026 — Quick Reference Guide

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers Kotlin syntax from basics to coroutines. Try examples live at play.kotlinlang.org. Last updated: April 2026 Variables Syntax Description val name = "Alex" Immutable (read-only) — cannot reassign var count = 0 Mutable — can reassign val age: Int = 25 Explicit type annotation const val PI = 3.14 Compile-time constant (top-level or object only) val name = "Alex" // type inferred as String var score = 0 // type inferred as Int score = 10 // OK — var can be reassigned // name = "Sam" // ERROR — val cannot be reassigned Basic Types Type Example Notes Int 42 32-bit integer Long 42L 64-bit integer Double 3.14 64-bit decimal Float 3.14f 32-bit decimal Boolean true, false String "hello" Immutable Char 'A' Single character Type Conversions val x: Int = 42 val d: Double = x.toDouble() // 42.0 val s: String = x.toString() // "42" val i: Int = "123".toInt() // 123 val safe: Int? = "abc".toIntOrNull() // null Null Safety Syntax Description String? Nullable type — can hold null name?.length Safe call — returns null if name is null name ?: "default" Elvis operator — use default if null name!! Not-null assertion — throws if null (avoid this) name?.let { ... } Execute block only if not null val name: String? = null val len = name?.length // null (no crash) val safe = name ?: "Unknown" // "Unknown" // val crash = name!!.length // throws NullPointerException String Templates val name = "Alex" println("Hello $name") // Hello Alex println("Length: ${name.length}") // Length: 4 println("Sum: ${2 + 3}") // Sum: 5 Functions // Regular function fun greet(name: String): String { return "Hello $name" } // Single-expression function fun greet(name: String) = "Hello $name" // Default parameters fun greet(name: String = "World") = "Hello $name" // Named arguments greet(name = "Alex") // Unit return type (void equivalent) fun log(message: String) { println(message) } Control Flow if / else (is an expression) val max = if (a > b) a else b when (replaces switch) when (x) { 1 -> println("one") 2, 3 -> println("two or three") in 4..10 -> println("between 4 and 10") is String -> println("it is a string") else -> println("something else") } // Guard conditions in when (Kotlin 2.2+) when (val result = fetchData()) { is Result.Success if result.data.isNotEmpty() -> show(result.data) is Result.Success -> showEmpty() is Result.Error -> showError(result.message) } // when as expression val label = when { score >= 90 -> "A" score >= 80 -> "B" else -> "C" } Loops for (i in 1..5) { } // 1, 2, 3, 4, 5 for (i in 1 until 5) { } // 1, 2, 3, 4 (or 1..<5) for (i in 1..<5) { } // 1, 2, 3, 4 (open-ended range, Kotlin 1.8+) for (i in 5 downTo 1) { } // 5, 4, 3, 2, 1 for (i in 0..10 step 2) { } // 0, 2, 4, 6, 8, 10 for (item in list) { } // iterate a collection list.forEachIndexed { index, item -> } Collections Type Create Mutable Version List listOf(1, 2, 3) mutableListOf(1, 2, 3) Set setOf(1, 2, 3) mutableSetOf(1, 2, 3) Map mapOf("a" to 1) mutableMapOf("a" to 1) Common Operations val numbers = listOf(1, 2, 3, 4, 5) numbers.filter { it > 2 } // [3, 4, 5] numbers.map { it * 2 } // [2, 4, 6, 8, 10] numbers.first() // 1 numbers.last() // 5 numbers.firstOrNull { it > 10 } // null numbers.any { it > 3 } // true numbers.all { it > 0 } // true numbers.count { it % 2 == 0 } // 2 numbers.sum() // 15 numbers.sorted() // [1, 2, 3, 4, 5] numbers.reversed() // [5, 4, 3, 2, 1] numbers.distinct() // remove duplicates numbers.take(3) // [1, 2, 3] numbers.drop(2) // [3, 4, 5] numbers.groupBy { it % 2 } // {1=[1,3,5], 0=[2,4]} numbers.associate { it to it * it } // {1=1, 2=4, 3=9, ...} numbers.flatMap { listOf(it, it * 10) } // [1,10,2,20,...] Map Operations val map = mapOf("a" to 1, "b" to 2) map["a"] // 1 map.getOrDefault("c", 0) // 0 map.keys // [a, b] map.values // [1, 2] map.entries // [a=1, b=2] map + ("c" to 3) // new map with c added Lambdas val double = { x: Int -> x * 2 } double(5) // 10 // Single parameter uses "it" val numbers = listOf(1, 2, 3) numbers.filter { it > 1 } // Trailing lambda numbers.fold(0) { acc, n -> acc + n } Classes // Data class — equals, hashCode, toString, copy generated data class User(val name: String, val age: Int) val user = User("Alex", 25) val copy = user.copy(age = 26) // Enum class enum class Color { RED, GREEN, BLUE } // Sealed class — restricted hierarchy sealed class Result { data class Success(val data: String) : Result() data class Error(val message: String) : Result() data object Loading : Result() } // Object — singleton object Database { fun connect() { } } // Companion object — static-like members class MyClass { companion object { fun create(): MyClass = MyClass() } } Extension Functions fun String.addExclamation() = "$this!" "Hello".addExclamation() // "Hello!" fun List<Int>.secondOrNull(): Int? = if (size >= 2) this[1] else null Scope Functions Function Object ref Return Use case let it Lambda result Null checks, transformations run this Lambda result Object config + compute result with this Lambda result Group calls on an object apply this Object itself Object configuration also it Object itself Side effects (logging, validation) // let — execute block if not null val length = name?.let { it.length } // apply — configure a builder/mutable object val paint = Paint().apply { color = Color.RED strokeWidth = 4f } // also — side effects val list = mutableListOf(1, 2).also { println("Before: $it") } // run — compute a result val result = service.run { connect() fetchData() } // with — group calls val info = with(user) { "$name is $age years old" } Coroutines Basics // Launch — fire and forget scope.launch { val data = fetchData() // suspend function updateUi(data) } // Async — returns a Deferred (future) val deferred = async { fetchData() } val result = deferred.await() // Parallel execution coroutineScope { val a = async { fetchA() } val b = async { fetchB() } println("${a.await()} ${b.await()}") } // Switch context withContext(Dispatchers.IO) { // Run on background thread readFile() } // Flow — reactive stream fun numbers(): Flow<Int> = flow { for (i in 1..3) { delay(100) emit(i) } } // collect is a suspend function — must be called inside a coroutine scope.launch { numbers().collect { println(it) } } Dispatcher Use case Dispatchers.Main UI updates Dispatchers.IO Network, database, file I/O Dispatchers.Default CPU-heavy computation Smart Casts // Kotlin auto-casts after a type check — no explicit cast needed fun printLength(x: Any) { if (x is String) { println(x.length) // x is auto-cast to String } } // Works with when too when (result) { is Result.Success -> println(result.data) is Result.Error -> println(result.message) } Value Classes // Wraps a value with zero runtime overhead (no extra object allocation) @JvmInline value class Email(val address: String) val email = Email("alex@example.com") // At runtime, this is just a String — no wrapper object Multi-line Strings val json = """ { "name": "Alex", "age": 25 } """.trimIndent() val sql = """ SELECT * FROM users WHERE age > 18 ORDER BY name """.trimIndent() Common Patterns Safe casting val x: Any = "hello" val s: String? = x as? String // "hello" val i: Int? = x as? Int // null (no crash) Destructuring val (name, age) = User("Alex", 25) val (key, value) = mapEntry takeIf / takeUnless val positiveNumber = number.takeIf { it > 0 } // number or null val nonBlank = name.takeUnless { it.isBlank() } // name or null // Chain with Elvis val port = config.getPort().takeIf { it in 1..65535 } ?: 8080 Lazy initialization val heavy: String by lazy { println("Computed!") "result" } Common Mistakes Mutable vs immutable collections — listOf() returns a read-only List. Use mutableListOf() if you need add() or remove(). Casting a List to MutableList is unsafe. ...

March 16, 2026 · 7 min

Jetpack Compose Text, Button, Image, and TextField: Complete Guide

You know layouts. You know modifiers. Now let’s learn the components you will use in every single screen — Text, Button, Image, and TextField. These are the building blocks of every Android app. Get comfortable with them and you can build almost anything. Text — Showing Words on Screen You have already used Text, but there is much more to it. Basic Text Text("Hello, World!") Styling Text Text( text = "Styled Text", fontSize = 24.sp, fontWeight = FontWeight.Bold, color = Color.Blue, letterSpacing = 1.sp, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() ) All the Style Options Property What It Does Example fontSize Text size 16.sp, 24.sp fontWeight Thickness FontWeight.Bold, FontWeight.Light fontStyle Italic or normal FontStyle.Italic color Text color Color.Red, Color(0xFF333333) textAlign Alignment TextAlign.Center, TextAlign.End letterSpacing Space between letters 2.sp lineHeight Space between lines 28.sp maxLines Maximum number of lines 1, 3 overflow What happens when text is too long TextOverflow.Ellipsis textDecoration Underline or strikethrough TextDecoration.Underline Truncating Long Text When text is too long for the available space: ...

March 16, 2026 · 9 min

What Are AI Coding Agents? The Complete Guide for Developers (2026)

A few years ago, AI coding tools just suggested the next line while you typed. Helpful, but you still wrote most of the code. That changed completely. In 2026, AI coding agents don’t just suggest — they plan, write, test, and ship code on their own. You describe what you want, and the agent builds it. It creates files, edits existing code, runs your tests, fixes failures, and opens a pull request. ...

March 15, 2026 · 10 min

Jetpack Compose Tutorial #3: Modifiers — The Secret to Styling Everything

In the previous tutorial, we learned how to arrange things on screen with Column, Row, and Box. But everything looked plain. No padding. No colors. No borders. That is where Modifiers come in. Modifiers are how you control everything about how a Composable looks and behaves — size, spacing, color, shape, click behavior, scrolling, and more. If layouts are the skeleton, modifiers are the skin and muscles. What is a Modifier? A Modifier is a chain of instructions that you attach to a Composable. Each instruction changes one thing about how it looks or acts. ...

March 15, 2026 · 9 min

Claude Is Giving 2x Usage for Free Right Now — Here's How to Get It

Anthropic just launched a promotion that doubles Claude’s usage limits — and it works on every plan, including free. Here is what you need to know. The Deal From March 13 to March 27, 2026, Claude doubles your usage limits during off-peak hours. Off-peak: Outside 8 AM – 2 PM Eastern (5 AM – 11 AM Pacific) What doubles: All usage limits — messages, tokens, everything Bonus usage doesn’t count toward your weekly limits That means if you use Claude in the evening, at night, or early morning, you get twice as much as usual — and it doesn’t eat into your regular quota. ...

March 14, 2026 · 3 min

How to Set Up Claude Code: Complete Beginner Guide (2026)

Claude Code is one of the most powerful AI coding tools in 2026. But setting it up for the first time can be confusing. Terminal-based. No GUI. No install wizard. This guide will walk you through everything — from installation to your first real coding session. What is Claude Code? Claude Code is an AI coding agent that runs in your terminal. You type what you want in plain English, and it reads your code, makes changes, runs commands, and even handles git — all by itself. ...

March 14, 2026 · 9 min

7 Best Free AI Coding Tools in 2026 (I Tested All of Them)

You don’t need to pay $20/month to use AI for coding. There are free tools that are actually good — some are even better than what we had with paid tools two years ago. I tested every major free AI coding tool in 2026. Here is what works, what doesn’t, and which one you should pick. Quick Comparison Tool Free Completions Free Chat Works In Best For GitHub Copilot 2,000/month 50 messages VS Code, JetBrains, Neovim Best all-around free option Gemini Code Assist 180,000/month Yes VS Code, JetBrains, Android Studio Most generous free tier Cursor Limited Limited Cursor (VS Code fork) Best editor experience Windsurf Limited Yes Windsurf (VS Code fork) Good agent features for free Amazon Q Developer Unlimited 50/month VS Code, JetBrains AWS developers Continue Unlimited Unlimited VS Code, JetBrains Open source, use any AI model Claude.ai Daily limit Yes Browser Best for complex questions Now let me break down each one. ...

March 14, 2026 · 10 min