branch
In Git, a movable name for one commit; committing on the branch moves the name forward to the new commit.
In more detail
A branch is a small file under .git/refs/heads holding one commit ID, so creating one copies no files and is instant even in a huge repository. Commits do not belong to a branch; a branch just marks where one line of work currently ends. When you commit, Git follows HEAD to the current branch and rewrites that file with the new ID.
Example
cat .git/refs/heads/mainRelated terms
- commit — A saved snapshot of the whole project in Git, together with its author, committer, time, message and a pointer to the commit before it.
- default branch — The branch a repository treats as its main line, usually main, which pull requests target by default.
- merge — Combining the work of two branches into one, either by moving a branch forward (a fast-forward) or by recording a merge commit.
- pull request — A request on a hosting service such as GitHub to merge one branch into another, with a page for review, discussion and automated checks.
- trunk — The single main branch that everyone integrates into, often called main.
- trunk-based development — A branching practice where developers merge small changes into one main branch, the trunk, at least once a day, keeping any other branches short-lived.
- Git Flow — A branching model published by Vincent Driessen in 2010 with long-lived main and develop branches plus feature, release and hotfix branches.
- git branch — The command that lists, creates, renames and deletes branches.
- ref — A Git name that points at a commit, such as a branch (refs/heads/main) or a tag (refs/tags/v1.0).
- HEAD — Git's pointer to where you are: normally the name of the current branch, and through it the current commit.
- main branch — The branch a repository treats as its primary line of work, usually named main (older repositories often use master).
- feature branch — A branch made for one piece of work, such as a feature or bug fix, and merged back when that work is done.
- Git — A free, open-source distributed version control system that records the history of a project as a chain of snapshots.
Taught in
- What Is a Pipeline? — Continuous Integration & Continuous Delivery Pipelines
- Triggers and the Event Model — Continuous Integration & Continuous Delivery Pipelines
- Speeding Up Builds: Caching Dependencies — Continuous Integration & Continuous Delivery Pipelines
- What is GitOps? — Continuous Integration & Continuous Delivery Pipelines
- Admin Processes And The Open Source Update — DevOps & Site Reliability Engineering
- Trunk-Based Development Versus Git Flow — DevOps & Site Reliability Engineering
- Decoupling Release From Deployment: Feature Flags — DevOps & Site Reliability Engineering
- Why Version Control, And Why Git Won — Advanced Git Internals & Distributed Workflows
- Installing Git, And Telling It Who You Are — Advanced Git Internals & Distributed Workflows
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- What A Commit Really Is — Advanced Git Internals & Distributed Workflows
- The Three Areas: Working Tree, Index, Repository — Advanced Git Internals & Distributed Workflows
- Staging Deliberately: status, add, add --patch — Advanced Git Internals & Distributed Workflows
- Committing, And What A Good Message Says — Advanced Git Internals & Distributed Workflows
- Reading History: log, show And diff — Advanced Git Internals & Distributed Workflows
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- A Branch Is A Moving Pointer — Advanced Git Internals & Distributed Workflows
- HEAD, And Why Detached HEAD Is Not An Error — Advanced Git Internals & Distributed Workflows
- Merging: Fast Forward Or A Merge Commit — Advanced Git Internals & Distributed Workflows
- Rebase: The Same Work, A Different History — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Clone, Forks, Push, And The Upstream Branch — Advanced Git Internals & Distributed Workflows
- Fetch Is Not Pull — Advanced Git Internals & Distributed Workflows
- The Pull Request, And Branch Naming — Advanced Git Internals & Distributed Workflows
- Reviewing Code Well — Advanced Git Internals & Distributed Workflows
- Why Conflicts Happen — Advanced Git Internals & Distributed Workflows
- Resolving A Conflict, Line By Line — Advanced Git Internals & Distributed Workflows
- Amend, And The One Hard Rule — Advanced Git Internals & Distributed Workflows
- Interactive Rebase: Squash, Reorder, Reword — Advanced Git Internals & Distributed Workflows
- Cherry Picking, Reflog, And Getting Work Back — Advanced Git Internals & Distributed Workflows
- Investigating History: blame, bisect And worktree — Advanced Git Internals & Distributed Workflows
- Tags And Releases — Advanced Git Internals & Distributed Workflows
- Trunk Based Development Versus Git Flow — Advanced Git Internals & Distributed Workflows
- The Workflow That Ran On A Stranger's Pull Request — GitHub Actions (GH-200) Exam Prep
- Triggers In Depth: Filters, Schedules And Dispatch — GitHub Actions (GH-200) Exam Prep
- Expressions, Contexts And The If That Is Always True — GitHub Actions (GH-200) Exam Prep
- Matrices, Needs And Concurrency: The Shape Of A Run — GitHub Actions (GH-200) Exam Prep
- Outputs, Artifacts, Caches And Job Summaries — GitHub Actions (GH-200) Exam Prep
- Why It Ran, Why It Did Not: Reading Runs, Jobs And Checks — GitHub Actions (GH-200) Exam Prep
- Failed Runs: Debug Logging And Re-Running The Right Jobs — GitHub Actions (GH-200) Exam Prep
- Logs And Artifacts Without The Browser: REST And The gh CLI — GitHub Actions (GH-200) Exam Prep
- Workflow Templates: Sharing Workflows Across An Organization — GitHub Actions (GH-200) Exam Prep
- Composite And Docker Actions: Troubleshooting And Immutable Releases — GitHub Actions (GH-200) Exam Prep
- Distributing And Versioning Actions: Tags, SHAs And Marketplace — GitHub Actions (GH-200) Exam Prep
- Governing Actions: Allow Lists, SHA Pinning And Rulesets — GitHub Actions (GH-200) Exam Prep
- Environments: Reviewers, Wait Timers And Deployment Rules — GitHub Actions (GH-200) Exam Prep
- Script Injection: When An Issue Title Becomes Code — GitHub Actions (GH-200) Exam Prep
- OIDC: Cloud Access Without Stored Keys — GitHub Actions (GH-200) Exam Prep
- Supply Chain: Pinning, Trusted Actions And Attestations — GitHub Actions (GH-200) Exam Prep
- Faster And Cheaper: Where The Minutes Go — GitHub Actions (GH-200) Exam Prep
- YAML-Reading Sprint: What Happens When This Runs? — GitHub Actions (GH-200) Exam Prep
- Full Mock And Review: Where Your Points Go — GitHub Actions (GH-200) Exam Prep
- If Elif Chains — Hands-on Python: Complete Video Course & Book
- Any Type As A Condition — Hands-on Python: Complete Video Course & Book
- Formatting, Linting And Style — Hands-on Python: Complete Video Course & Book
- Shipping: scripts, entry points and git — Hands-on Python: Complete Video Course & Book
- Branching With If, Elif And Else — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Functions, Return Values And Recursion — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- The Exception Family Tree — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep