From 485bcf6691c29e0b3a09bfb597ab7f0a71816b45 Mon Sep 17 00:00:00 2001 From: thomasyimgit Date: Sun, 5 Nov 2017 20:31:09 -0500 Subject: [PATCH] add checkout to remote branch --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 19ecfdc..11c4208 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ For clarity's sake all examples in this document use a customized bash prompt in - [I want to delete local branches that were deleted upstream](#i-want-to-delete-local-branches-that-were-deleted-upstream) - [I accidentally deleted my branch](#i-accidentally-deleted-my-branch) - [I want to delete a branch](#i-want-to-delete-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) - [Rebasing and Merging](#rebasing-and-merging) - [I want to undo rebase/merge](#undo-rebase) - [I rebased, but I don't want to force push.](#i-rebased-but-i-dont-want-to-force-push) @@ -600,6 +601,26 @@ To delete a local branch: (master)$ git branch -D my-branch ``` + +### I want to checkout to a remote branch that someone else is working on + +First, fetch all branches from remote: + +```sh +(master)$ git fetch --all +``` + +Say you want to checkout to `daves` from the remote. + +```sh +(master)$ git checkout --track origin/daves +Branch daves set up to track remote branch daves from origin. +Switched to a new branch 'daves' +``` + +(`--track` is shorthand for `git checkout -b [branch] [remotename]/[branch]`) + +This will give you a local copy of the branch `daves`, and any update that has been pushed will also show up remotely. ## Rebasing and Merging