This gem simplifies switching between git branches without losing uncommitted changes. Its meant as an alternative for "git checkout" and "git stash".
-
If the branch you are switching from contains uncommitted changes they will be automatically saved to the folder ~/.git-switch-branch/REPO_NAME/BRANCH_NAME.
-
If the branch you are switching to contains saved changes they will be automatically restored.
-
It makes it easier to sync uncommitted changes between computers.
Add this line to your application's Gemfile:
gem 'git_switch_branch'
And then execute:
$ bundle
Or install it yourself as:
$ gem install git_switch_branch
Basic usage is just:
$ gsb
This will give you a list of all branches to choose from.
$ 1. master
$ 2. 123-nasty-bug
If you know the name of the branch or part of the name you can do:
$ gsb 123
If you are using Dropbox you can easily sync your uncommitted changes between all your computers.
First create a folder inside your DropBox folder:
~/Dropbox/.git-switch-branch
Then create a link from it to ~/.git-switch-branch:
ln -s ~/Dropbox/.git-switch-branch ~/.git-switch-branch
Repeat this on all your computers.
- Empty files are not restored.
- Make it possible to find and automatically track remote branches.
- Use the Git gem more (instead of the git shell command).
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
git_switch_branch has been tested with:
- OS X Lion
- Ruby 1.8.7, 1.9.3
- Git 1.7.7, 1.7.8, 1.8.0