Git checkout <latest branch you were working on> command

Is there a command to permit checkout the last branch? Like:

git checkout --recent

  • How to set tab size for pager used in git diff?
  • Git - remote: error: cannot run hooks/post-receive: No such file or directory
  • git: How to view commits to a single branch
  • How to use git merge --squash?
  • Moving from Private GitHub Repo to Public and Private
  • Web API (like github REST API) for a personal Git server repo to enable “git log”?
  • or

    git checkout --previous

    The idea is when you switch branch too often you it’s easy to forget the branch you were working before the current one. Also if there’s a way to set a alias for this that would be valide.

  • Git : Determine if branch is in a merge conflict state
  • GitIgnore - Ignoring bin/ but including bin/*.refresh
  • git svn clone large repo under Windows: out of memory - not a large file issue
  • Git track a remote branch using netbeans
  • In Git, removing DLL and PDB files that have accidently been committed
  • “Not currently on any branch” after doing a commit
  • One Solution collect form web for “Git checkout <latest branch you were working on> command”

    What you’re looking for is -

    git checkout -
    

    For example, say you’re on branch foo, and there exists a branch bar.

    * foo
    bar
    

    Check out bar

    > git checkout bar
    
    foo
    * bar
    

    Going back to foo

    > git checkout -
    
    * foo
    bar
    

    The - “shortcut” also works for the cd and ls commands from within a bash terminal.

    Git Baby is a git and github fan, let's start git clone.