{"id":23672754,"url":"https://github.com/falkz/squash2stash","last_synced_at":"2025-12-19T14:30:24.328Z","repository":{"id":269756684,"uuid":"908334676","full_name":"FalkZ/squash2stash","owner":"FalkZ","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-25T22:26:36.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-25T23:19:29.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FalkZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-25T19:16:31.000Z","updated_at":"2024-12-25T22:26:39.000Z","dependencies_parsed_at":"2024-12-25T23:19:36.483Z","dependency_job_id":"613a599d-cfa5-42bc-882d-69b0e0c968d0","html_url":"https://github.com/FalkZ/squash2stash","commit_stats":null,"previous_names":["falkz/squash2stash"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fsquash2stash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fsquash2stash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fsquash2stash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fsquash2stash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FalkZ","download_url":"https://codeload.github.com/FalkZ/squash2stash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239699419,"owners_count":19682537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-29T11:19:13.900Z","updated_at":"2025-12-19T14:30:23.968Z","avatar_url":"https://github.com/FalkZ.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# squash2stash\n\n\u003e A script that squashes your current git branch changes and stashes them.\n\n# Motivation\n\nLike many developers, I often create multiple commits during development with messages like \"_WIP_\" or \"_fixed XYZ_\". While these commits help track progress, I discovered they:\n\n- Create a messy commit history\n- Can make rebasing unnecessarily complex\n\nMy solution:\n\nSquash all changes from your working branch into a single change and stash it. This allows you to:\n\n- Create a fresh, \"clean\" branch\n- Apply the stashed changes\n- Make a single, well-documented commit\n- Rebase with ease\n\n# Installation\n\nAdd this to your `.zshrc`:\n\n```sh\nsquash2stash() {\n        local target_branch=${1:-origin/main}\n        git fetch\n        local main_commit=\"$(git merge-base HEAD $target_branch)\"\n        local current_branch=\"$(git rev-parse --abbrev-ref HEAD)\"\n        git switch -c temp/squash2stash # create temporary branch to not change current branch directly\n        git reset --soft \"$main_commit\"\n        git stash\n        git switch $current_branch\n        git branch -d temp/squash2stash\n}\n```\n\n# Usage\n\n1. Checkout the branch you want to squash and stash\n2. Run `squash2stash [source branch]`\n   (The source branch is typically the branch you branched from)\n3. All changes made since branching will now be in your stash\n\n# Is it safe?\n\nThis command never modifies your existing branches, making it safe to use.\n\n# How it works\n\nConsider a develop branch with commits A, B \u0026 C. You're currently on develop at the square marker.\n\n```mermaid\ngitGraph\n   commit id: \"X\"\n   commit id: \"Y\"\n   branch develop\n   checkout develop\n   commit id: \"A\"\n   commit id: \"B\"\n   checkout main\n   commit id: \"Z\"\n     checkout develop\n   commit id: \"C\" type: HIGHLIGHT\n   checkout develop\n```\n\nWhen you run:\n\n```\nsquash2stash main\n```\n\nAll commits in your current branch (A, B, C) will be squashed and stashed. Commits shared with the source branch (X, Y from main) will not be stashed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalkz%2Fsquash2stash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffalkz%2Fsquash2stash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalkz%2Fsquash2stash/lists"}