4

Created a new branch off master to work on but never actually changed any code. Week later I'm coming back to start work and now master is many changes ahead.

Since I've not changed anything, would it be best to just rebase or merge or something else from master branch so I can start work with most up-to-date codebase?

eComEvo
  • 9,511
  • 21
  • 69
  • 123
  • i'd go with a rebase. or dropping the branch and creating it again on top of your master branch. i see no point in doing a merge and adding a commit for no real change. – Alex Tartan Oct 11 '15 at 22:57
  • Possible duplicate of [Git workflow and rebase vs merge questions](https://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-merge-questions) – Jess Bowers Feb 14 '18 at 15:23

1 Answers1

5

You can rebase your branch and replay all of your (nonexistent) commits on the tip of master.

git checkout <branch>
git rebase master

I've suggest this pattern because you haven't shared any commits by pushing. As long as this invariant is maintained rebasing keeps commit histories clean and relevant.

Ben Campbell
  • 3,518
  • 1
  • 24
  • 30