How to push only to a branch of my fork of a Github repo, after a pull request has already been made
Say I cloned a public Github repo, called
REPO. I then made a branch, did some work, and submitted a work-in-progress pull request to
REPO. Whenever I push a new commit, it goes to both my clone, and
REPO. This kicks off time consuming CI tests on
I switch between working on two computers, and it would be nice to commit to my clone of the repo, without adding it to the current PR on
REPO. Then I could push, switch computers, and pull from the branch on my fork. When I’m ready, I can push a batch of commits to the pull request on
What is the best way to do this?
One Solution collect form web for “How to push only to a branch of my fork of a Github repo, after a pull request has already been made”
Create a new branch (say,
feature) from the branch you created pull request (say,
$ git checkout pr-branch # checkout to 'pr-branch' $ git checkout -b feature # create and checkout to 'feature' branch
Then, when you are done with
feature branch, merge the
feature branch with the
$ git push origin feature # push 'feature' branch changes to remote $ git checkout pr-branch # checkout to 'pr-branch' $ git pull origin feature # pull 'feature' branch changes into local 'pr-branch' $ git push origin pr-branch # update remote 'pr-branch'
Now, your PR on
REPO should be updated automatically since
pr-branch is updated with
feature branch commits/changes.
If you have to switch between two computers and work on
feature branch then, just push your latest
feature branch changes to remote and pull from another computer to start working from latest codes.
# computer-1 $ git pull origin feature # do some commits here... $ git push origin feature # computer-2 $ git pull origin feature # start working from latest codes and do commit... $ git push origin feature