Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Clone the repo: `git clone git@github.com:username/repo.git`
  2.  
  3. By default, you only have the master branch locally:
  4.  
  5. ```
  6. ~/repo$ git branch
  7. * master
  8. ```
  9.  
  10. Fetch the target branch: `git fetch origin branch-name`
  11.  
  12. Check it out: `git checkout origin/branch-name` (note the slash)
  13.  
  14. Git will tell you that you're in a `detached HEAD` state. That's okay.
  15.  
  16. Now create a new local branch with the same name: `git checkout -b branch-name`
  17.  
  18. Tell Git to follow the changes of the remote branch: `git branch -u origin/branch-name`
  19.  
  20. And you're done.
  21.  
  22. ```
  23. ~/repo$ git branch
  24. master
  25. * other-branch
  26. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement