Jeremy Rodi
Jeremy Rodi

Reputation: 2505

How does git-receive-pack work?

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?

Upvotes: 17

Views: 14477

Answers (2)

Kevin Bedell
Kevin Bedell

Reputation: 13404

According to the man page:

http://schacon.github.io/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/

Upvotes: 20

captncraig
captncraig

Reputation: 23098

There is quite detailed documentation of the receive pack protocol in git's repository. You can see it here https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt.

Upvotes: 8

Related Questions