Elad Benda Elad Benda - 10 months ago 54
Git Question

after git rebase master, try to rebase from master again show the merge conflicts again

I have two branches:


I had few commits and pushes to

Now I want to rebase

and then merge it to
and commit all my new changes as one big commit.

Here is what I did:

git fetch --all
git checkout br2
git rebase origin/master
git rebase --continue until I resolved all conflicts

-checked everything is working

git checkout master
git merge br2

git commit review (my alias...can ignore)

git checkout br2

git rebase master (should have done nothing, no?)

q: I had to pull first and fix all conflicts again. Why did this has happen?

q: How should i have squashed all the commits into one commit before
git commit review

I saw this:

git rebase -i master
That command will show a list of each commit, as such:

pick fb554f5 This is commit 1
pick 2bd1903 This is commit 2
pick d987ebf This is commit 3

# Rebase 9cbc329..d987ebf onto 9cbc329
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
Edit the summary shown to you by the rebase command, leaving the commit you want to be the main commit as "pick" and changing all subsequent "pick" commands as "squash":

pick fb554f5 This is commit 1
squash 2bd1903 This is commit 2
squash d987ebf This is commit 3

but I wasn't sure as I have checked out master already

Answer Source

q1) If you've already pushed some changes to b2, you would need to use force push. git push origin/b2 --force. This will replace the remote origin/b2 with the rebased local version of b2.

q2) That should work for squashing the commits.