Alana Storm
Alana Storm

Reputation: 166046

What am I Fetching with git fetch?

Context: I've been using git for about 6 months and I'm comfortable with it on a surface level. However, some of what I'm doing is still black box voodoo that I'd like to understand better.

When I run something like

git fetch upstream
git merge upstream/master

I understand this is the equivalent of a pull. First a fetch something, then I use that something to perform the merge.

What I don't understand is what IS it I'm fetching, and where does this information live? I understand conceptually I'm fetching all the branches on the upstream remote repository, but it seems like that information would need to live somewhere, and that's where my brain and understanding of git can only come up with "What am I Fetching with git Fetch?"

Upvotes: 2

Views: 103

Answers (3)

Matt Ball
Matt Ball

Reputation: 359776

You're fetching commit objects which represent the incoming changes, into your local copy of the repository. The actual data is stored under the .git directory, until you git-merge, at which point it will also be represented in the working directory.


Want to know all the gory details? Check out Pro Git, Chapter 9: Git Internals.

Upvotes: 4

ayoy
ayoy

Reputation: 3835

You're fetching git objects, stored in .git/objects directory, and the information about remote head object (.git/FETCH_HEAD).

Upvotes: 2

CharlesB
CharlesB

Reputation: 90276

The information from fetch is stuffed in .git folder, as if it was another branch. The local repository holds information about commits of all branches, including the branches that are fetched from remote repositories.

Upvotes: 2

Related Questions