Skip to content

Instantly share code, notes, and snippets.

@alechko
Created September 29, 2015 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alechko/5dbeb0564e48ad9daf2d to your computer and use it in GitHub Desktop.
Save alechko/5dbeb0564e48ad9daf2d to your computer and use it in GitHub Desktop.
Working with forked repo
#!/bin/bash
# sometimes, when checking a pull request, I wanted to commit my own changes into the forked repo
# and return it to the developer for more work. I wanted to do that without cloning his repo.
# So what I'm doing is first, setup a remote:
git remote add [upstream_name] https://[myusername]@github.com/[remoteuser]/[repo].git
# you can see it now under
git remote -v
# then sync branches
git fetch [upstream_name]
# then I checkout to a new branch (if I didn't do it earlier)
git checkout -b [newbranch]
# set-upstream for our new branch to point to the new [upstream_name]
git branch --set-upstream [newbranch] [upstream_name]/[remote_branch]
# the next will pull the changes that are submitted in the pull request
git pull https://[myusername]@github.com/[remoteuser]/[repo].git [remote_branch]
# then I make my code changes, and after commiting, I push my changes to forked repo by:
git push [upstream_name] HEAD:[remote_branch]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment