Is it possible in Git to switch to another branch without checking out all files?
After switching branch I need to delete all files, regenerate them, commit and swit
you can make use of
1. git checkout -f <new-branch>
2. git cherry-pick -x <previous-branch-commit-id>
previous-branch-commit-id is the commit from where you want to copy old the data.
Yes, you can do this.
git symbolic-ref HEAD refs/heads/otherbranch
If you need to commit on this branch, you'll want to reset the index too otherwise you'll end up committing something based on the last checked out branch.
git reset
If you are simply trying to change where a remote branch points, you can do it with "git push" without touching your local copy.
http://kernel.org/pub/software/scm/git/docs/git-push.html
The format of a <refspec> parameter is an optional plus +, followed by the source ref <src>, followed by a colon :, followed by the destination ref <dst>. It is used to specify with what <src> object the <dst> ref in the remote repository is to be updated.
eg, to update foo to commit c5f7eba do the following:
git push origin c5f7eba:foo
Not sure if that's what you were after or not.
Wouldn't be a better solution to have two working directories (two working areas) with one repository, or even two repositories?
There is git-new-workdir tool in contrib/
section to help you with this.
You can overwrite your HEAD file with a different branch name:
echo "ref: refs/heads/MyOtherBranch" > .git/HEAD