Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exact git command line equivalents to the "Pull Request" and "Fork Repo" buttons in Github

what is Github doing when I click on these buttons? Let's say I do a pull request in Github. What is the git command I would type in (git pull ....?). And how about forking? What is Github doing behind the scenes.

like image 219
David West Avatar asked Feb 20 '13 17:02

David West


People also ask

Is there a git fork command?

There is no git fork command. From the command line you can clone a Git repo, you can pull from a Git repo and you can fetch updates from a Git repo, but there is no git fork command if you're working with a standard Git installation.

What is pull command in GitHub?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.


2 Answers

A fork can be thought of as equivalent to git clone <URL for source repo> although the repo on GitHub is bare (no working tree "checked out" files) so behind the scenes they might be doing something like git clone --bare <URL>.

A pull request is asking the owner of the source repo to pull your changes in to their repo ... so there isn't an equivalent git command. It's a bit like emailing the owner of that repo to say "here are some changes I've made, hope you like them". If they accept the pull request they would, basically, then do the equivalent of git pull <URL for your repo>.

like image 137
Gavin Avatar answered Sep 19 '22 18:09

Gavin


If you are wondering how emulate the behavior of forking and pull requests, VonC has answered that far better than I can here. Basically clone and pull.

If you are interested in what GitHub is actually doing behind the scenes, its a little more complicated. Zach Holman, @holman on GitHub, recently gave a talk "How To Build A GitHub" where he goes into detail about their implementation.

like image 33
Chris Knadler Avatar answered Sep 20 '22 18:09

Chris Knadler