git rebase

Situation

Branch master has commits after older feature branch and now need continue feature branch, but without doing git merge master – better using rebase like below.

$ git checkout feature
$ git rebase master

Real example

Before

* commit b2823b3076e16100979e52a8413fc7d6467d3f8e (HEAD -> master)
| Date:   Sun Feb 26 10:19:37 2023 +0100
|
|     commit to master 3
|
* commit b8d3673372f1f011eb298602a86173143634db8d
| Date:   Sun Feb 26 10:17:01 2023 +0100
|
|     commit to master 2
|
* commit ce5772542ef89713713a4903026d79c3efeceb9c
| Date:   Sun Feb 26 10:16:21 2023 +0100
|
|     commit to master 1
|
| * commit 712aa0a72a3ad3a9e8e57398b79561f8aa60c05f (feature)
| | Date:   Sun Feb 26 10:18:17 2023 +0100
| |
| |     commit to feature 2
| |
| * commit ec673a55003ebd317cfc1e98bc87c2ef9da90156
|/  Date:   Sun Feb 26 10:15:37 2023 +0100
|
|       commit to feature 1
|
* commit 6e5b8936ca70698b6249794264b4bed0fc498cc0
  Date:   Sun Feb 26 10:14:53 2023 +0100

      init

After git merge master

*   commit b667155f84bc2a926ec9c7d78250f4269c2cb460 (HEAD -> feature)
|\  Merge: 712aa0a b2823b3
| | Date:   Sun Feb 26 10:31:13 2023 +0100
| |
| |     Merge branch 'master' into feature
| |
| * commit b2823b3076e16100979e52a8413fc7d6467d3f8e (master)
| | Date:   Sun Feb 26 10:19:37 2023 +0100
| |
| |     commit to master 3
| |
| * commit b8d3673372f1f011eb298602a86173143634db8d
| | Date:   Sun Feb 26 10:17:01 2023 +0100
| |
| |     commit to master 2
| |
| * commit ce5772542ef89713713a4903026d79c3efeceb9c
| | Date:   Sun Feb 26 10:16:21 2023 +0100
| |
| |     commit to master 1
| |
* | commit 712aa0a72a3ad3a9e8e57398b79561f8aa60c05f
| | Date:   Sun Feb 26 10:18:17 2023 +0100
| |
| |     commit to feature 2
| |
* | commit ec673a55003ebd317cfc1e98bc87c2ef9da90156
|/  Date:   Sun Feb 26 10:15:37 2023 +0100
|
|       commit to feature 1
|
* commit 6e5b8936ca70698b6249794264b4bed0fc498cc0
  Date:   Sun Feb 26 10:14:53 2023 +0100

      init

After git rebase master

* commit 05faab0f8711528a5c26f538aefc011219693e62 (HEAD -> feature)
| Date:   Sun Feb 26 10:18:17 2023 +0100
|
|     commit to feature 2
|
* commit 8add6e328c548705cc4ba2bce577038c0b35cfa6
| Date:   Sun Feb 26 10:15:37 2023 +0100
|
|     commit to feature 1
|
* commit b2823b3076e16100979e52a8413fc7d6467d3f8e (master)
| Date:   Sun Feb 26 10:19:37 2023 +0100
|
|     commit to master 3
|
* commit b8d3673372f1f011eb298602a86173143634db8d
| Date:   Sun Feb 26 10:17:01 2023 +0100
|
|     commit to master 2
|
* commit ce5772542ef89713713a4903026d79c3efeceb9c
| Date:   Sun Feb 26 10:16:21 2023 +0100
|
|     commit to master 1
|
* commit 6e5b8936ca70698b6249794264b4bed0fc498cc0
  Date:   Sun Feb 26 10:14:53 2023 +0100

      init