From 7a68447ac98806a7638586d582b24be39678cc80 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Fri, 8 Dec 2017 15:39:07 -0500 Subject: [PATCH] Add an example using `set-head` This is just one of many possible examples using set-head, but which might be useful for others to discover the command. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 26b4090..f69f205 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ For clarity's sake all examples in this document use a customized bash prompt in - [I want to rename a branch](#i-want-to-rename-a-branch) - [I want to checkout to a remote branch that someone else is working on](#i-want-to-checkout-to-a-remote-branch-that-someone-else-is-working-on) - [I want to create a new remote branch from current local one](#i-want-to-create-a-new-remote-branch-from-current-local-one) + - [I want to set my HEAD to track the default remote branch](#i-want-to-set-my-head-to-track-the-default-remote-branch) - [Rebasing and Merging](#rebasing-and-merging) - [I want to undo rebase/merge](#i-want-to-undo-rebasemerge) - [I rebased, but I don't want to force push](#i-rebased-but-i-dont-want-to-force-push) @@ -755,6 +756,23 @@ $ git push The behavior of the other modes of ```git push``` is described in the doc of push.default. + +### I want to set my HEAD to track the default remote branch + +By checking your remote branches, you can see which remote branch your HEAD is tracking. In some cases, this is not the desired branch. + +```sh +$ git branch -rr + origin/HEAD -> origin/gh-pages + origin/master +``` + +To change `origin/HEAD` to track `origin/master`, you can run this command: + +```sh +$ git remote set-head origin --auto +origin/HEAD set to master +``` ## Rebasing and Merging