Skip to content

Commit

Permalink
Merge pull request k88hudson#108 from thomasyimgit/checkout-remote-br…
Browse files Browse the repository at this point in the history
…anch

add checkout to remote branch
  • Loading branch information
RichardLitt authored Nov 6, 2017
2 parents 2a86ef4 + 485bcf6 commit 688ab59
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -600,6 +601,26 @@ To delete a local branch:
(master)$ git branch -D my-branch
```

<a name="i-want-to-checkout-to-a-remote-branch-that-someone-else-is-working-on"></a>
### 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

Expand Down

0 comments on commit 688ab59

Please sign in to comment.