I'm trying to gain a more thorough understanding of git.
Can someone give me a simple line-by-line explanation of what basic git pull
output means? Example:
remote: Counting objects: 11, done. remote: Compressing objects: 100% (5/5), done. remote: Total 7 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (7/7), done. From ssh://my.remote.host.com/~/git/myproject * branch master -> FETCH_HEAD Updating 9d447d2..f74fb21 Fast forward app/controllers/myproject_controller.rb | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
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.
The git pull command first runs a git fetch command to check for changes. The fetch operation returns the metadata for our commits . Then, the git pull command retrieves all the changes we have made to our remote repository and changes our local files.
The "git pull" command. The pull command is used to access the changes (commits)from a remote repository to the local repository. It updates the local branches with the remote-tracking branches. Remote tracking branches are branches that have been set up to push and pull from the remote repository.
Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
Under the hood, git pull
is git fetch
followed by git merge
. Here's the fetch portion:
remote: Counting objects: 11, done. remote: Compressing objects: 100% (5/5), done. remote: Total 7 (delta 2), reused 0 (delta 0)
At this point, you've told the remote what you want. It finds all the objects it needs to give you (counting them in the process, I believe), compresses them for faster transfer over the network, and then reports what it's sending you. Objects may be blobs, trees, commits, or tags - see for example the git book for more information.
Unpacking objects: 100% (7/7), done.
You receive the pack (set of compressed objects) and unpack it.
From ssh://my.remote.host.com/~/git/myproject * branch master -> FETCH_HEAD
You've fetched the branch 'master' from the given remote; the ref FETCH_HEAD now points to it. Now we move on to the merge - precisely, git will merge FETCH_HEAD (the remote's master branch) into your current branch (presumably master).
Updating 9d447d2..f74fb21 Fast forward
It turns out that you haven't diverged from the remote's master branch, so the merge is a fast-forward (a trivial merge where it simply moves you forward in the history). Git notes the original position of your master branch (9d447d2) and the new position (f74fb21) it's been fast-forwarded to. If you had diverged from the remote's master branch, you'd see the output of a recursive merge here - Merge made by recursive
, possibly along with some Auto-merged <file>
and (oh no!) merge conflicts!
app/controllers/myproject_controller.rb | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
Finally, it shows you the diffstat between the original and post-merge position of your master branch; this is basically what you'd get from git diff --stat master@{1} master
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With