2

Let's say I have a feature branch derived from master. Master is ahead several commits. I want to include lastest updates from master into my feature branch.

What is the correct approach?

  1. git pull
  2. git pull --rebase
  3. git pull origin feature
  4. git pull origin master
  5. git rebase origin/master
  6. git merge origin/master
  7. Something else?

Sorry for lame question, but I really do have little bit of a mess in these commands. Description of the differences between the commands would be highly appreciated.

romanzdk
  • 930
  • 11
  • 30
  • 2
    Does this answer your question? [How to keep a branch synchronized/updated with master?](https://stackoverflow.com/questions/16329776/how-to-keep-a-branch-synchronized-updated-with-master) – evolutionxbox Jul 15 '22 at 15:28
  • 1
    @evolutionxbox that specific question mentions that the branch in question is "a continuous branch", which would lean the best answer towards `merge`, whereas this question, specifying a feature branch without any additional context, would probably lean towards `rebase`. Since both are presented in the top answers to that other question, I'm not opposed to that being the dup, though, I assume there is probably a better dup match. – TTT Jul 15 '22 at 19:05

1 Answers1

1

git rebase origin/master is the answer to your question.

devmgod
  • 26
  • 5
  • 2
    It's one of many correct answers. Also, if `origin/master` hasn't been updated (with fetch), this will do nothing – evolutionxbox Jul 15 '22 at 15:40
  • git rebase or git merge are possible answers but git rebase is clean and the best fit for this question. – devmgod Jul 15 '22 at 15:47
  • 2
    This question [has been answered before](https://stackoverflow.com/questions/16329776/how-to-keep-a-branch-synchronized-updated-with-master) – evolutionxbox Jul 15 '22 at 15:47