In Git you can (and usually should) switch branches "in place". For example if you are on branch 'master', and want to start working on branch 'devel', you can simply use
$ git checkout devel
and your working area would reflect branch 'devel'. You need usually to be in a clean state, i.e. do not have uncomitted changes.
As to setup between "work", "home" and "bare" repositories:
First, a matter of configuration. I'll assume there that both on "work" and on "home" computer there is configured "bare" (or whatever you name your bare repository), with configuration that looks like the following (you can use "git remote add" to create it):
[remote "bare"]
url = [email protected]:/path/to/repo.git
fetch = +refs/heads/*:refs/remotes/bare/*
push = refs/heads/*:refs/heads/*
There can be other remote configuration, for example about tags (e.g. fetch = +refs/tags/*:refs/tags/*
etc.), but I am omitting it for simplicity.
Second, let's assume that you are working on branch 'master', and uou have the following configuration for such branch both in "work" and "home" repositories:
[branch "master"]
remote = bare
merge = refs/heads/master
You can of course have similar configurations for other branches.
Let's now examine some example sessions. You are either at "work" or at "home".
First thing you should do before starting work is to get updates from the "bare" repository. I'm assuming here that you are on 'master' branch. You can do that using "git pull bare", or with above branch configuration simply "git pull":
$ git pull bare
Updating 8818df8..9ad6770
Fast forward
foo | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
"Fast-forward" means here that "bare" repository is in advance of the repository you are working in (and tat you don't have any changes that are not in "bare" repository). If you are working either from "work", or from "home", but not on those simultaneously, this should be the situation you get.
Now do some work (this is an example session only):
$ edit, edit, edit
$ git commit -a
$ git add somefile
$ git commit -a
$ git commit --amend
Note that you better finish your work so that there are no uncomited changes, but it is not a strict requirement. If you leave some uncomitted changes, you can finish commit before "git pull", but then you wouldn't get fast-forward but a merge. Or you can use "git stash" to stash away your oncomitted changes, and then apply stash (unstash) them after pull.
After finishing your work, you push your changes to the "bare" repository, so you would be able to access your work in other repository.
$ git push bare
Counting objects: 8, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 493 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
To [email protected]:/path/to/repo.git
9ad6770..4230584 master -> master
I hope that such example would help.