2

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?

Reef Rashid
  • 59
  • 1
  • 3
  • 6
  • 1
    Possible 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 Answers3

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:

  1. Run a git pull from your master branch
  2. 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