Git: set branch to current ref

Checkout the branch with -B: this will reset the branch to HEAD, which is the current ref.

git checkout -B <branch> 

From the docs:

If -B is given, is created if it doesn’t exist;
otherwise, it is reset. This is the transactional equivalent of

$ git branch -f <branch> [<start point>]
$ git checkout <branch>

that is to say, the branch is not reset/created unless “git
checkout” is successful.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)