What is the difference between 'git pull' and 'git pull origin master'? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question















marked as duplicate by Jaa-c, torek git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

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 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














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?










share|improve this question















marked as duplicate by Jaa-c, torek git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

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 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












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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

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 git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

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 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
















  • 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















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












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 to git pull origin master






share|improve this answer




















  • 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


















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. The git pull command is a combination of
    git fetch and git 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 do
    git pull origin master, it simply fetches a copy of the master
    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.






share|improve this answer





























    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.



    1. When creating a local branch for an existing remote branch:
      git branch --track branch_name origin/branch_name





    share|improve this answer



























      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



      1. If your branch is set to "master", then git pull and git pull origin master will do the same thing.


      2. If your branch is set to "master", Git pull and git pull origin some-other-branch will be different


      3. If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different






      share|improve this answer





























        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 to git pull origin master






        share|improve this answer




















        • 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















        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 to git pull origin master






        share|improve this answer




















        • 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













        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 to git pull origin master






        share|improve this answer












        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 to git pull origin master







        share|improve this answer












        share|improve this answer



        share|improve this answer










        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

















        • 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













        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. The git pull command is a combination of
          git fetch and git 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 do
          git pull origin master, it simply fetches a copy of the master
          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.






        share|improve this answer


























          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. The git pull command is a combination of
            git fetch and git 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 do
            git pull origin master, it simply fetches a copy of the master
            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.






          share|improve this answer
























            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. The git pull command is a combination of
              git fetch and git 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 do
              git pull origin master, it simply fetches a copy of the master
              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.






            share|improve this answer














            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. The git pull command is a combination of
              git fetch and git 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 do
              git pull origin master, it simply fetches a copy of the master
              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.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 31 at 18:55









            Peter Mortensen

            13k1983111




            13k1983111










            answered Aug 31 at 5:42









            Sana Jahan

            31126




            31126




















                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.



                1. When creating a local branch for an existing remote branch:
                  git branch --track branch_name origin/branch_name





                share|improve this answer
























                  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.



                  1. When creating a local branch for an existing remote branch:
                    git branch --track branch_name origin/branch_name





                  share|improve this answer






















                    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.



                    1. When creating a local branch for an existing remote branch:
                      git branch --track branch_name origin/branch_name





                    share|improve this answer












                    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.



                    1. When creating a local branch for an existing remote branch:
                      git branch --track branch_name origin/branch_name






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 31 at 5:41









                    Chukwuemeka Inya

                    1,07339




                    1,07339




















                        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



                        1. If your branch is set to "master", then git pull and git pull origin master will do the same thing.


                        2. If your branch is set to "master", Git pull and git pull origin some-other-branch will be different


                        3. If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different






                        share|improve this answer


























                          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



                          1. If your branch is set to "master", then git pull and git pull origin master will do the same thing.


                          2. If your branch is set to "master", Git pull and git pull origin some-other-branch will be different


                          3. If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different






                          share|improve this answer
























                            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



                            1. If your branch is set to "master", then git pull and git pull origin master will do the same thing.


                            2. If your branch is set to "master", Git pull and git pull origin some-other-branch will be different


                            3. If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different






                            share|improve this answer














                            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



                            1. If your branch is set to "master", then git pull and git pull origin master will do the same thing.


                            2. If your branch is set to "master", Git pull and git pull origin some-other-branch will be different


                            3. If your branch is set to "some-other-branch", then Git pull and git pull origin master will be different







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Aug 31 at 14:02

























                            answered Aug 31 at 5:21









                            paulsm4

                            73.9k897119




                            73.9k897119












                                Popular posts from this blog

                                How to check contact read email or not when send email to Individual?

                                Bahrain

                                Postfix configuration issue with fips on centos 7; mailgun relay