Git Merge vs Rebase

Git Merge vs Rebase

When you run git pull, Git fetches the changes from the remote repository and merges them into your local branch. This can create a merge commit, which can clutter your history with unnecessary commits.

Instead, you can configure Git to use rebase instead of merge when pulling changes. This will replay your local commits on top of the fetched commits, resulting in a cleaner history.

  git config --global pull.rebase true

Now git pull replays your commits on top of GitHub’s. There’s no merge commit, no editor, and the history stays a straight line instead of 50 “Merge branch” commits.

Also, do this

  git config --global rebase.autoStash true