You can merge both branches with git merge
. I don't recommend using git rebase
on this case since you said both branches have already been published to the repository server.
I've created the following situation (described on your post):
$ git co A
$ git lg --all
* 4df39d7 - (HEAD, A) 2nd commit on A (9 seconds ago)
| * f1f57d8 - (B) 1st commit on B (39 seconds ago)
|/
* 8228446 - (master) . (2 minutes ago)
$ git co B
$ git lg --all
* 4df39d7 - (A) 2nd commit on A (2 minutes ago)
| * f1f57d8 - (HEAD, B) 1st commit on B (3 minutes ago)
|/
* 8228446 - (master) . (4 minutes ago)
So assuming we're in branch B
you can merge A
by doing: git merge A
Which turns the history into this:
$ git merge A
$ git lg --all
* 5517453 - (HEAD, B) Merge branch 'A' into B (2 minutes ago)
|\
| * 4df39d7 - (A) 2nd commit on A (5 minutes ago)
* | f1f57d8 - 1st commit on B (6 minutes ago)
|/
* 8228446 - (master) . (7 minutes ago)
Additional note:
The git lg
and git co
are aliases that I've created in order to make it easier to work with the git command line. They stand for (as configured on my .gitconfig
):
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
co = checkout