I created a branch on the github website that wasn't in my local repository. How do I bring that branch to my local computer, edit it, and then push it back to my github account?
Asked
Active
Viewed 3,305 times
2
-
1Possible duplicate of [How do I check out a remote Git branch?](https://stackoverflow.com/questions/1783405/how-do-i-check-out-a-remote-git-branch) – tom Jun 27 '17 at 01:21
3 Answers
1
Run
git fetch
to retrieve the new branch from GitHub's server and then use
git checkout YOUR-BRANCH-NAME
to switch to that branch.
When you have committed your changes, push them to GitHub using
git push
See Git Branching - Remote Branches for more information.

tom
- 21,844
- 6
- 43
- 36
1
In your local workdir enter:
git fetch origin newbranch
git checkout newbranch
where newbranch
is the name of your new branch.
Then do your edits, and when finished do:
git push origin newbranch

Ho Zong
- 523
- 1
- 4
- 22
0
You have to update your local files first. In your terminal:
- Run a git pull from your master branch
- git checkout (branch_name you created on github website)
Or
You can bring your codebase back to the exact commit of a branch you are talking about. In the repo under the specific branch you should see all of your commits. The number on the righthand side of each commit is the SHA number. You can copy this and then use the following:
git fetch origin SHA git checkout FETCH_HEAD

Code Sloth
- 1
- 1