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
More Related Contents:
- Difference between git checkout –track origin/branch and git checkout -b branch origin/branch
- git: Switch branch and ignore any changes without committing
- Switch branch and ignore any changes without committing
- How do you create a remote Git branch?
- How can I delete all Git branches which have been merged?
- Trimming Git Commits/Squashing Git History
- What is a tracking branch?
- Listing and deleting Git commits that are under no branch (dangling?)
- What’s the difference between “git reset” and “git checkout”?
- How do you stop tracking a remote branch in Git?
- Show just the current branch in Git
- Rebasing a branch including all its children
- How to checkout in Git by date?
- Using Git, show all commits that are in one branch, but not the other(s)
- How to get the changes on a branch in Git
- Creating a new empty branch for a new project
- git merge: Removing files I want to keep!
- Renaming branches remotely in Git
- Git: Merge to master while automatically choosing to overwrite master files with branch
- Git undo local branch delete
- error: Your local changes to the following files would be overwritten by checkout
- Is there any way to git checkout previous branch?
- Get back the changes after accidental checkout?
- Git: How to find out on which branch a tag is?
- Renaming a branch in GitHub
- Git: Merge a Remote branch locally
- Different default remote (tracking branch) for git pull and git push
- Block a git branch from being pushed
- Restore file from old commit in git
- Commit a file to a Different Branch Without Checkout