wchargin
wchargin

Reputation: 16047

Git: merge behind changes

Scenario:

How can I use git merge to place the merge commit before all my commits that have not been pushed? It's okay if this messes up the SHAs of the unpushed commits.

Do I need to git rebase something?

Upvotes: 4

Views: 2919

Answers (2)

Pigueiras
Pigueiras

Reputation: 19356

If you want to git pull has a rebase behaviour by default, you can also put this in your configuration:

git config --global branch.autosetuprebase always

This option in the configuration will set the rebase behaviour when you pull for every branch. If you want to do a pull with a merge after setting this you can do it with the option --no-rebase.

git pull --no-rebase

Upvotes: 1

mvp
mvp

Reputation: 116437

Simplest way to avoid "annoying" merge commit:

git pull --rebase

This would automatically rebase your changes on computer B such that history appears to be linear. For more information about rebase, look at this answer.

If you have already pushed your merge commit from computer B to github, then it is too late: this merge commit will stay there forever. If not, you can still rebase. But it is easier to simply git pull --rebase to avoid it in the future.

Upvotes: 4

Related Questions