Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to push to someone's fork?

Tags:

git

github

gitlab

I work for an open-source project and forked it already. Someone has forked it too and has been working with some interesting ideas which won't be pushed to origin soon. I want to help him thus I cloned his fork to my computer. However, I can't push directly my work to his fork. I can't fork him either since I have a fork from origin already. What should I do? Thanks

like image 540
Tony Avatar asked Oct 24 '25 20:10

Tony


1 Answers

Suppose your repository looked like this:

enter image description here

#Add the forked repo as another remote to your local repository
git remote add someone https://fork.url                 #create remote called "someone"

#fetch the changes from that remote
git fetch someone

enter image description here

#rebase the work you want to send onto the fork's work
git branch for-someone my-branch                        #create branch "for-someone" at "my-branch"
git rebase master for-someone --onto someone/master     #take commits from the "for-someone" branch down to your "master" branch and rebase it onto someone's "master" branch

enter image description here

#then push your changes to the other remote
git push someone for-someone                            #push branch "for-someone" to the "someone" remote

Insert more appropriate remote and branch names.

like image 189
Jeff Mercado Avatar answered Oct 27 '25 11:10

Jeff Mercado