What is the difference between 'git pull' and 'git pull origin master'? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
This question already has an answer here:
Differences between âgit pullâ commands when pulling from origin?
2 answers
What is the difference between git pull
and git pull origin master
?
What if I am on a branch other than master
, will the two commands achieve a different result?
git
marked as duplicate by Jaa-c, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Aug 31 at 6:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
6
down vote
favorite
This question already has an answer here:
Differences between âgit pullâ commands when pulling from origin?
2 answers
What is the difference between git pull
and git pull origin master
?
What if I am on a branch other than master
, will the two commands achieve a different result?
git
marked as duplicate by Jaa-c, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Aug 31 at 6:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you are new to Git, I recommend avoidinggit pull
for some time. First, get yourself familiar with bothgit fetch
andgit merge
. If you plan to usegit rebase
, get familiar with that too. Then, later, you can usegit pull
as a convenience command, knowing that what it does is rungit fetch
with some arguments, followed by eithergit merge
orgit pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!
â torek
Aug 31 at 5:55
That said, the short answer to your question is that they are usually different, if you are not onmaster
now.
â torek
Aug 31 at 5:56
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
This question already has an answer here:
Differences between âgit pullâ commands when pulling from origin?
2 answers
What is the difference between git pull
and git pull origin master
?
What if I am on a branch other than master
, will the two commands achieve a different result?
git
This question already has an answer here:
Differences between âgit pullâ commands when pulling from origin?
2 answers
What is the difference between git pull
and git pull origin master
?
What if I am on a branch other than master
, will the two commands achieve a different result?
This question already has an answer here:
Differences between âgit pullâ commands when pulling from origin?
2 answers
git
git
edited Aug 31 at 18:49
Peter Mortensen
13k1983111
13k1983111
asked Aug 31 at 5:14
kgbph
330118
330118
marked as duplicate by Jaa-c, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Aug 31 at 6:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jaa-c, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Aug 31 at 6:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you are new to Git, I recommend avoidinggit pull
for some time. First, get yourself familiar with bothgit fetch
andgit merge
. If you plan to usegit rebase
, get familiar with that too. Then, later, you can usegit pull
as a convenience command, knowing that what it does is rungit fetch
with some arguments, followed by eithergit merge
orgit pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!
â torek
Aug 31 at 5:55
That said, the short answer to your question is that they are usually different, if you are not onmaster
now.
â torek
Aug 31 at 5:56
add a comment |Â
If you are new to Git, I recommend avoidinggit pull
for some time. First, get yourself familiar with bothgit fetch
andgit merge
. If you plan to usegit rebase
, get familiar with that too. Then, later, you can usegit pull
as a convenience command, knowing that what it does is rungit fetch
with some arguments, followed by eithergit merge
orgit pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!
â torek
Aug 31 at 5:55
That said, the short answer to your question is that they are usually different, if you are not onmaster
now.
â torek
Aug 31 at 5:56
If you are new to Git, I recommend avoiding
git pull
for some time. First, get yourself familiar with both git fetch
and git merge
. If you plan to use git rebase
, get familiar with that too. Then, later, you can use git pull
as a convenience command, knowing that what it does is run git fetch
with some arguments, followed by either git merge
or git pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!â torek
Aug 31 at 5:55
If you are new to Git, I recommend avoiding
git pull
for some time. First, get yourself familiar with both git fetch
and git merge
. If you plan to use git rebase
, get familiar with that too. Then, later, you can use git pull
as a convenience command, knowing that what it does is run git fetch
with some arguments, followed by either git merge
or git pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!â torek
Aug 31 at 5:55
That said, the short answer to your question is that they are usually different, if you are not on
master
now.â torek
Aug 31 at 5:56
That said, the short answer to your question is that they are usually different, if you are not on
master
now.â torek
Aug 31 at 5:56
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
5
down vote
accepted
Remember, a pull is a fetch and a merge.
git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.
git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master,
git pull
is equivalent togit pull origin master
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
add a comment |Â
up vote
2
down vote
First, let us understand what git pull
is:
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. Thegit pull
command is a combination ofgit fetch
andgit merge
.git merge
will download the content from
the remote repository. Once the content is downloaded,git merge
will
merge the content to your local repository. A new merge commit will
be created and HEAD updated to point at the new commit.Now that we know what
git pull
does, when we dogit pull origin master
, it simply fetches a copy of themaster
branch from the original repository, and merges it with the current
branch that you have checked out.
For more information, you can go to this link.
add a comment |Â
up vote
1
down vote
Git pull = Git fetch + Git merge.
git pull origin master
Let's say you are on local/master, and run this command, git will fetch commits from origin/master and then merge it into local/master.
git pull
This is a shorthand for pulling commits into local branch that is tracking a remote branch.
And that brings the question, how does one make a local branch track a remote branch.
As far as I know, there are two common ways to do so:
1. When pushing for the first time:
git push -u origin branch_name
The -u
flag tells git to make the local branch track the remote branch.
- When creating a local branch for an existing remote branch:
git branch --track branch_name origin/branch_name
add a comment |Â
up vote
1
down vote
From the documentation:
https://git-scm.com/docs/git-pull
git pull [<options>] [<repository> [<refspec>â¦âÂÂ]]
git-pull - Fetch from and integrate with another repository or a local
branch
...
Default values for and are read from the
"remote" and "merge" configuration for the current branch as set by
git-branch[1] --track.
So
If your branch is set to "master", then git pull and git pull origin master will do the same thing.
If your branch is set to "master", Git pull and git pull origin some-other-branch will be different
If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Remember, a pull is a fetch and a merge.
git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.
git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master,
git pull
is equivalent togit pull origin master
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
add a comment |Â
up vote
5
down vote
accepted
Remember, a pull is a fetch and a merge.
git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.
git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master,
git pull
is equivalent togit pull origin master
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Remember, a pull is a fetch and a merge.
git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.
git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master,
git pull
is equivalent togit pull origin master
Remember, a pull is a fetch and a merge.
git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.
git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master,
git pull
is equivalent togit pull origin master
answered Aug 31 at 5:23
Nagaraj
1194
1194
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
add a comment |Â
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
Good explanation. Short and straight to the point. Thanks.
â kgbph
Aug 31 at 6:12
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
"a pull is a fetch and a merge" Isn't that over-simplified?
â Peter Mortensen
Aug 31 at 19:48
add a comment |Â
up vote
2
down vote
First, let us understand what git pull
is:
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. Thegit pull
command is a combination ofgit fetch
andgit merge
.git merge
will download the content from
the remote repository. Once the content is downloaded,git merge
will
merge the content to your local repository. A new merge commit will
be created and HEAD updated to point at the new commit.Now that we know what
git pull
does, when we dogit pull origin master
, it simply fetches a copy of themaster
branch from the original repository, and merges it with the current
branch that you have checked out.
For more information, you can go to this link.
add a comment |Â
up vote
2
down vote
First, let us understand what git pull
is:
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. Thegit pull
command is a combination ofgit fetch
andgit merge
.git merge
will download the content from
the remote repository. Once the content is downloaded,git merge
will
merge the content to your local repository. A new merge commit will
be created and HEAD updated to point at the new commit.Now that we know what
git pull
does, when we dogit pull origin master
, it simply fetches a copy of themaster
branch from the original repository, and merges it with the current
branch that you have checked out.
For more information, you can go to this link.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
First, let us understand what git pull
is:
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. Thegit pull
command is a combination ofgit fetch
andgit merge
.git merge
will download the content from
the remote repository. Once the content is downloaded,git merge
will
merge the content to your local repository. A new merge commit will
be created and HEAD updated to point at the new commit.Now that we know what
git pull
does, when we dogit pull origin master
, it simply fetches a copy of themaster
branch from the original repository, and merges it with the current
branch that you have checked out.
For more information, you can go to this link.
First, let us understand what git pull
is:
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. Thegit pull
command is a combination ofgit fetch
andgit merge
.git merge
will download the content from
the remote repository. Once the content is downloaded,git merge
will
merge the content to your local repository. A new merge commit will
be created and HEAD updated to point at the new commit.Now that we know what
git pull
does, when we dogit pull origin master
, it simply fetches a copy of themaster
branch from the original repository, and merges it with the current
branch that you have checked out.
For more information, you can go to this link.
edited Aug 31 at 18:55
Peter Mortensen
13k1983111
13k1983111
answered Aug 31 at 5:42
Sana Jahan
31126
31126
add a comment |Â
add a comment |Â
up vote
1
down vote
Git pull = Git fetch + Git merge.
git pull origin master
Let's say you are on local/master, and run this command, git will fetch commits from origin/master and then merge it into local/master.
git pull
This is a shorthand for pulling commits into local branch that is tracking a remote branch.
And that brings the question, how does one make a local branch track a remote branch.
As far as I know, there are two common ways to do so:
1. When pushing for the first time:
git push -u origin branch_name
The -u
flag tells git to make the local branch track the remote branch.
- When creating a local branch for an existing remote branch:
git branch --track branch_name origin/branch_name
add a comment |Â
up vote
1
down vote
Git pull = Git fetch + Git merge.
git pull origin master
Let's say you are on local/master, and run this command, git will fetch commits from origin/master and then merge it into local/master.
git pull
This is a shorthand for pulling commits into local branch that is tracking a remote branch.
And that brings the question, how does one make a local branch track a remote branch.
As far as I know, there are two common ways to do so:
1. When pushing for the first time:
git push -u origin branch_name
The -u
flag tells git to make the local branch track the remote branch.
- When creating a local branch for an existing remote branch:
git branch --track branch_name origin/branch_name
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Git pull = Git fetch + Git merge.
git pull origin master
Let's say you are on local/master, and run this command, git will fetch commits from origin/master and then merge it into local/master.
git pull
This is a shorthand for pulling commits into local branch that is tracking a remote branch.
And that brings the question, how does one make a local branch track a remote branch.
As far as I know, there are two common ways to do so:
1. When pushing for the first time:
git push -u origin branch_name
The -u
flag tells git to make the local branch track the remote branch.
- When creating a local branch for an existing remote branch:
git branch --track branch_name origin/branch_name
Git pull = Git fetch + Git merge.
git pull origin master
Let's say you are on local/master, and run this command, git will fetch commits from origin/master and then merge it into local/master.
git pull
This is a shorthand for pulling commits into local branch that is tracking a remote branch.
And that brings the question, how does one make a local branch track a remote branch.
As far as I know, there are two common ways to do so:
1. When pushing for the first time:
git push -u origin branch_name
The -u
flag tells git to make the local branch track the remote branch.
- When creating a local branch for an existing remote branch:
git branch --track branch_name origin/branch_name
answered Aug 31 at 5:41
Chukwuemeka Inya
1,07339
1,07339
add a comment |Â
add a comment |Â
up vote
1
down vote
From the documentation:
https://git-scm.com/docs/git-pull
git pull [<options>] [<repository> [<refspec>â¦âÂÂ]]
git-pull - Fetch from and integrate with another repository or a local
branch
...
Default values for and are read from the
"remote" and "merge" configuration for the current branch as set by
git-branch[1] --track.
So
If your branch is set to "master", then git pull and git pull origin master will do the same thing.
If your branch is set to "master", Git pull and git pull origin some-other-branch will be different
If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different
add a comment |Â
up vote
1
down vote
From the documentation:
https://git-scm.com/docs/git-pull
git pull [<options>] [<repository> [<refspec>â¦âÂÂ]]
git-pull - Fetch from and integrate with another repository or a local
branch
...
Default values for and are read from the
"remote" and "merge" configuration for the current branch as set by
git-branch[1] --track.
So
If your branch is set to "master", then git pull and git pull origin master will do the same thing.
If your branch is set to "master", Git pull and git pull origin some-other-branch will be different
If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different
add a comment |Â
up vote
1
down vote
up vote
1
down vote
From the documentation:
https://git-scm.com/docs/git-pull
git pull [<options>] [<repository> [<refspec>â¦âÂÂ]]
git-pull - Fetch from and integrate with another repository or a local
branch
...
Default values for and are read from the
"remote" and "merge" configuration for the current branch as set by
git-branch[1] --track.
So
If your branch is set to "master", then git pull and git pull origin master will do the same thing.
If your branch is set to "master", Git pull and git pull origin some-other-branch will be different
If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different
From the documentation:
https://git-scm.com/docs/git-pull
git pull [<options>] [<repository> [<refspec>â¦âÂÂ]]
git-pull - Fetch from and integrate with another repository or a local
branch
...
Default values for and are read from the
"remote" and "merge" configuration for the current branch as set by
git-branch[1] --track.
So
If your branch is set to "master", then git pull and git pull origin master will do the same thing.
If your branch is set to "master", Git pull and git pull origin some-other-branch will be different
If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different
edited Aug 31 at 14:02
answered Aug 31 at 5:21
paulsm4
73.9k897119
73.9k897119
add a comment |Â
add a comment |Â
If you are new to Git, I recommend avoiding
git pull
for some time. First, get yourself familiar with bothgit fetch
andgit merge
. If you plan to usegit rebase
, get familiar with that too. Then, later, you can usegit pull
as a convenience command, knowing that what it does is rungit fetch
with some arguments, followed by eithergit merge
orgit pull
with additional arguments. Once you're familiar with each of the two commands, the whole thing put together will also make sense. Until then, though, it won't!â torek
Aug 31 at 5:55
That said, the short answer to your question is that they are usually different, if you are not on
master
now.â torek
Aug 31 at 5:56