Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does git-receive-pack work?

Tags:

git

I would like to know how git-receive-pack works, because I have quite literally no idea what happens with it. Can anyone shed some light on this mystery?

like image 472
Jeremy Rodi Avatar asked May 19 '12 03:05

Jeremy Rodi


People also ask

What does git upload pack do?

Description. Invoked by git fetch-pack, learns what objects the other side is missing, and sends them after packing. This command is usually not invoked directly by the end user.

Does git push do a fetch?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.

What protocol does git use?

Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git. Here we'll discuss what they are and in what basic circumstances you would want (or not want) to use them.


1 Answers

According to the man page:

http://schacon.github.com/git/git-receive-pack.html

This command is usually not invoked directly by the end user. The UI for the protocol is on the git send-pack side, and the program pair is meant to be used to push updates to remote repository. For pull operations, see git-fetch-pack(1).

The command allows for creation and fast-forwarding of sha1 refs (heads/tags) on the remote end (strictly speaking, it is the local end git-receive-pack runs, but to the user who is sitting at the send-pack end, it is updating the remote. Confused?)

Even the person writing the man page thinks it's confusing, so don't blame yourself it you don't understand it!

Basically, this is part of the code that receives commits on the remote server that were packed up and sent by send-pack on your local machine when you do a git push.

It's not important to understand the specifics behind it -- as the docs say, it's not a command you should ever actually type.

If you're really deeply interested in how it works internally, a couple of good places to start might be:

The Wikipedia Page on Git (Software), The Git Website itself, or The free book, Pro Git

Or, you can always go look the 'c' code up for that command in the source code right here on github.

http://git-scm.com/

like image 59
Kevin Bedell Avatar answered Sep 26 '22 21:09

Kevin Bedell