Skip to main content
added 3 characters in body
Source Link

In the simplest terms, git pullgit pull does a git fetchgit fetch followed by a git mergegit merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pullgit pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

Rollback to Revision 22
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.


It is helpful to keep in mind that when working on any Git respository on any particular machine, the repository contains a copy of all branches from all remotes as well as a copy of each local branch you have done some work on.

You can see this using git branch -a, which should show your local branches, including master, and all branches from all remotes.

master
feature/my-feature-branch
remotes/origin/master
remotes/origin/my-feature-branch
remotes/another-remote-machine/master
remotes/another-remote-machine/my-feature-branch

Above, I have indicated the existance of a remote origin repo as well as another remote by another name another-remote-machine.

Note you do not necessarily have to have a copy of each branch on all repositories. (Remotes and local.) It will depend on when you have synchronized things by running git pull, git push, git fetch, from the different machines/repositories involved.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.


It is helpful to keep in mind that when working on any Git respository on any particular machine, the repository contains a copy of all branches from all remotes as well as a copy of each local branch you have done some work on.

You can see this using git branch -a, which should show your local branches, including master, and all branches from all remotes.

master
feature/my-feature-branch
remotes/origin/master
remotes/origin/my-feature-branch
remotes/another-remote-machine/master
remotes/another-remote-machine/my-feature-branch

Above, I have indicated the existance of a remote origin repo as well as another remote by another name another-remote-machine.

Note you do not necessarily have to have a copy of each branch on all repositories. (Remotes and local.) It will depend on when you have synchronized things by running git pull, git push, git fetch, from the different machines/repositories involved.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

Updated to add some useful information about how remotes work in general
Source Link
user2138149
  • 19.1k
  • 32
  • 167
  • 336

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.


It is helpful to keep in mind that when working on any Git respository on any particular machine, the repository contains a copy of all branches from all remotes as well as a copy of each local branch you have done some work on.

You can see this using git branch -a, which should show your local branches, including master, and all branches from all remotes.

master
feature/my-feature-branch
remotes/origin/master
remotes/origin/my-feature-branch
remotes/another-remote-machine/master
remotes/another-remote-machine/my-feature-branch

Above, I have indicated the existance of a remote origin repo as well as another remote by another name another-remote-machine.

Note you do not necessarily have to have a copy of each branch on all repositories. (Remotes and local.) It will depend on when you have synchronized things by running git pull, git push, git fetch, from the different machines/repositories involved.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

In the simplest terms, git pull does a git fetch followed by a git merge.


git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.

git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.


It is helpful to keep in mind that when working on any Git respository on any particular machine, the repository contains a copy of all branches from all remotes as well as a copy of each local branch you have done some work on.

You can see this using git branch -a, which should show your local branches, including master, and all branches from all remotes.

master
feature/my-feature-branch
remotes/origin/master
remotes/origin/my-feature-branch
remotes/another-remote-machine/master
remotes/another-remote-machine/my-feature-branch

Above, I have indicated the existance of a remote origin repo as well as another remote by another name another-remote-machine.

Note you do not necessarily have to have a copy of each branch on all repositories. (Remotes and local.) It will depend on when you have synchronized things by running git pull, git push, git fetch, from the different machines/repositories involved.

Updated to latest version of docs, since previous information is now out of date
Source Link
user2138149
  • 19.1k
  • 32
  • 167
  • 336
Loading
Shorten.
Source Link
Mateen Ulhaq
  • 28.1k
  • 22
  • 122
  • 157
Loading
Add documentation link. Reword, shorten for clarity.
Source Link
Mateen Ulhaq
  • 28.1k
  • 22
  • 122
  • 157
Loading
deleted 4 characters in body
Source Link
John Smith
  • 7.5k
  • 7
  • 52
  • 63
Loading
Combine "git fetch" explanation into single paragraph.
Source Link
Mateen Ulhaq
  • 28.1k
  • 22
  • 122
  • 157
Loading
Improved reference to git pull documentation
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading
added 1 character in body
Source Link
Alec
  • 9.8k
  • 8
  • 45
  • 71
Loading
added quote from the documentation which is a more detailed version of the first sentence of the current answer
Source Link
icc97
  • 13.2k
  • 9
  • 85
  • 99
Loading
Rollback to Revision 11 - Edit approval overridden by post owner or moderator
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading
Made the sentences concise by removing unnecessary phrases/words.
Source Link
Loading
added 7 characters in body
Source Link
Vikrant
  • 5.1k
  • 18
  • 54
  • 77
Loading
While that was a good diagram, it's not really useful for this question because it doesn't even mention git merge.
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading
Loading
Add link to relevant git documentation
Source Link
A.L
  • 10.8k
  • 10
  • 74
  • 108
Loading
Loading
Clarified answer, because as it was previously worded, it wasn't quite clear and correct.
Source Link
user456814
user456814
Loading
Rollback to Revision 3
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading
Updated the answer since git pull may also call git rebase.
Source Link
Loading
Formatted code.
Source Link
Ry-
  • 226.5k
  • 56
  • 497
  • 504
Loading
added 43 characters in body
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading
Source Link
Greg Hewgill
  • 1.0m
  • 193
  • 1.2k
  • 1.3k
Loading