{"id":30105710,"url":"https://github.com/nathan-fiscaletti/git-switch","last_synced_at":"2025-08-10T00:19:02.865Z","repository":{"id":301636183,"uuid":"1009879104","full_name":"nathan-fiscaletti/git-switch","owner":"nathan-fiscaletti","description":"A fast, interactive terminal UI for switching between git branches.","archived":false,"fork":false,"pushed_at":"2025-07-31T01:49:34.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-08T04:50:33.587Z","etag":null,"topics":["branches","git","terminal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathan-fiscaletti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-06-27T22:00:48.000Z","updated_at":"2025-07-31T01:49:19.000Z","dependencies_parsed_at":"2025-06-27T23:18:28.447Z","dependency_job_id":"58a8c377-03e4-4fc7-a5dd-3b8e26fc772c","html_url":"https://github.com/nathan-fiscaletti/git-switch","commit_stats":null,"previous_names":["nathan-fiscaletti/git-switch"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/nathan-fiscaletti/git-switch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathan-fiscaletti%2Fgit-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathan-fiscaletti%2Fgit-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathan-fiscaletti%2Fgit-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathan-fiscaletti%2Fgit-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathan-fiscaletti","download_url":"https://codeload.github.com/nathan-fiscaletti/git-switch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathan-fiscaletti%2Fgit-switch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269656981,"owners_count":24454748,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["branches","git","terminal"],"created_at":"2025-08-10T00:19:01.533Z","updated_at":"2025-08-10T00:19:02.843Z","avatar_url":"https://github.com/nathan-fiscaletti.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"https://github.com/user-attachments/assets/d22fadbd-bf6e-412e-80be-f2218536642c\n\n# git-switch\n\nA fast, interactive terminal UI for switching between git branches. Built with [tcell](https://github.com/gdamore/tcell) for a smooth, cross-platform experience.\n\nSwitching branches with `git checkout` or `git switch` can be slow, especially in repositories with many branches. **git-switch** makes it easy to quickly find and switch branches with just a few keystrokes.\n\n## Features\n\n- **Fuzzy search**: Instantly filter branches as you type.\n- **Pinned Branches**: A configurable list of branches that will always show at the top of the list.\n- **Keyboard navigation**: Use arrow keys to move, Enter to switch, and Esc/Ctrl+C to quit.\n- **Git Checkout**: Works as a stand-in replacement for the `git checkout` command.\n- **Custom Impelementation**: Works as a general branch selector that can return to stdout.\n- **Public API**: Can be easily integrated into your own Go projects.\n\n## Installation\n\n```sh\ngo install github.com/nathan-fiscaletti/git-switch@latest\n```\n\n\u003e [!NOTE]\\\n\u003e git-switch by default installs as the command `git-switch`. I highly recommend that you alias the `git-switch` command to `sw` in your shell for ease-of-use. The rest of this documentation will make the assumption that you have. If not, use `git-switch` instead of `sw` for each command.\n\u003e \n\u003e ```powershell\n\u003e # Windows Powershell\n\u003e \"`nset-alias sw git-switch\" | out-file -append -encoding utf8 $profile; . \u003e $profile\n\u003e \n\u003e # Bash (use .zshrc for zsh, etc.)\n\u003e echo \"alias sw='git-switch'\" \u003e\u003e ~/.bashrc \u0026\u0026 source ~/.bashrc\n\u003e ```\n\n## Usage\n\n### Interactive Mode\n\nJust run:\n\n```sh\nsw\n```\n\n- Start typing to filter branches.\n- Use **Up/Down** arrows to select.\n- Press **Enter** to checkout the selected branch.\n- Press **Esc** or **Ctrl+C** to exit.\n\n### Git Checkout Override\n\nArguments passed to `git-switch` are automatically forwarded to `git checkout`.\n\n```sh\n# Checkout a branch\nsw \u003cbranch-name\u003e\n# Create a new branch\nsw -b \u003cbranch-name\u003e\n# etc...\n```\n\n## Internal Commands\n\n\u003e [!TIP]\\\n\u003e Passing `-x` to `git-switch` will tell it you are executing an internal command.\n\n### Pinned Branches\n\nA pinned branch always shows at the top of the list of branches in the switcher.\n\n```sh\n# While a branch is checked out\nsw -x pin\nsw -x unpin\n```\n\nBy default, the currently checked out branch will be pinned/un-pinned. If you wish to pin/un-pin another branch, you can pass it in as an optional parameter.\n\n```sh\nsw -x pin \u003cbranch\u003e\nsw -x unpin \u003cbranch\u003e\n```\n\nYou can clear all pinned branches by running\n\n```sh\nsw -x unpin all\n```\n\n### Popping branches\n\nAny time you change branches using `git-switch`, your previous branch is stored. You can get back to it easily by using the `pop` command.\n\n```sh\nsw -x pop\n```\n\n\u003e [!WARNING]\\\n\u003e If you check out a branch using `git` directly, `git-switch` will not be aware of the change. If you intend to use `sw -x pop`, you should always switch branches using `git-switch`.\n\n### Using git-switch as a general branch selector\n\nYou can use git-switch to select a branch and have the selected branch returned to the caller. \n\nWhen using this mode the branch will not be automatically checked out, but instead printed to stdout.\n\n```powershell\n# Windows Powershell\n$branch = sw -x pipe\necho $branch\n\n# Bash\nbranch=$(sw -x pipe)\necho $branch\n```\n\n### Using the interactive branch selector in your own project\n\nInstall the package in your project using\n\n```\ngo get github.com/nathan-fiscaletti/git-switch\n```\n\nThe interactive branch selector is exposed in the [`pkg`](./pkg) package.\n\n```go\npackage main\n\nimport (\n    sw \"github.com/nathan-fiscaletti/git-switch/pkg\"\n)\n\nfunc main() {\n    branchSelector, err := sw.NewBranchSelector(sw.BranchSelectorArguments{\n        CurrentBranch:      currentBranch,\n        Branches:           branches,\n        PinnedBranches:     pinnedBranches,\n        PinnedBranchPrefix: \"★\",\n        WindowSize:         10,\n        SearchLabel:        \"search branch\",\n    })\n    if err != nil {\n        panic(err)\n    }\n\n    b, err := branchSelector.PickBranch()\n    if err != nil {\n        panic(err)\n    }\n\n    // ... use b ...\n}\n```\n\n## Configuration\n\nConfig File Location:\n```\nWindows:  %APPDATA%\\.gitswitch\\config\nLinux:    $HOME/.config/.gitswitch/config\nmacOS:    $HOME/Library/Application Support/.gitswitch/config\n```\n\nConfiguration Values:\n- `window-size`: The maximum number of branches to display at one time. (Default: 10)\n- `pinned-branch-prefix`: The prefix to display before pinned branches. (Default: ★)\n- `prune-remote-branches`: Will automatically run `git remote prune` for each remote before listing branches. (Default: false)\n\n## License\n\nMIT (See [LICENSE](./LICENSE))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathan-fiscaletti%2Fgit-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathan-fiscaletti%2Fgit-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathan-fiscaletti%2Fgit-switch/lists"}