The idea is such that I made a branch (for example, branch1 ) with the master 'a, I worked in it and I want to do a git rebase master , but for example, I know that the master been updated. Next, I need to do this:

 git checkout master git pull git checkout branch1 git rebase master git push ... 

Is it possible to update the local master 'and not switching from the current branch? What could be done one command to update and immediately rebase ?


UPDATE : I will try to clarify the question =). It would be very convenient for me to update the following local branch without switching to it. By "update" I mean not only the history of commits, but also the local files themselves, so that I can compare files or rebase based on the local branch. In other words, combine the first three commands in the above example. But, and this is quite an important "but", if possible avoid git checkout master .

In this example, the master shown only for some clarity. In a real project, there are several branches that are very different, and the number of files is beyond the limits, and therefore switching between these branches is quite a long procedure.

    1 answer 1

     git fetch git rebase origin/master 
    • Do I understand correctly? git fetch update my local master branch? Although no, in this situation the story will be updated and I will rebase the new story. Right? - spirit
    • 2
      @spirit git fetch update all the origin/* flowers, but the local ones will not touch. - D-side
    • @ D-side Well, yes, or rather, it will update the history of all origin/* branches. And I just need to update the files. So that I could compare the files from my branch with the files in the master - spirit
    • 3
      @spirit files in commits. Commits in branches. In response, there is a re-raise to the branch received from the server, without merge it to the follow-up local (what you did was git pull ). In fact, your method is higher, but without unnecessary steps due to an extra branch. Although I myself use your own method, since in the git some brief forms of commands rely on the tracking branch , and therefore I try to maintain a local branch that keeps track of the remote one. - D-side
    • one
      @spirit Record them in && - Pavel Mayorov