>>>>> mike <mikaelpetterson-pkbjnfxxiarbdgjk7y7...@public.gmane.org>:

> I have had a branch, feature_xyz, for a long time ( yes I know I should not 
> but it was not my call). Problem is I have not updated it with changes from 
> master. So I started to do a regular rebase ( i want to keep history):

> git fetch origin master
> git rebase origin/master

> After a while with conflicting patches (over 30...) I guess that there must 
> be an easier way to do this,

> So anyone out there with an better idea I am open to new ideas. What do you 
> suggest?

git checkout feature_xyz
git fetch
git merge origin/master

No history will be lost with this.  feature_xyz will get a new commit
from the merge operation, but that commit will create no problem when
feature_xyz later is merged into master.

Ie. what you have before the merge is this:

 feature_xyz --o--o--o--o--

 orgigin/master --o--o--o--o


What you have after the merge, is this:

 feature_xyz --o--o--o--o----o 
                            /
 origin/master --o--o--o--o


What you have after origin/master has more commits is something like this:

 feature_xyz --o--o--o--o----o 
                            /
 origin/master --o--o--o--o--o--o--o


What you have after feature_xyz gets even more commits, is something like this:

 feature_xyz --o--o--o--o----o--o--o
                            /
 origin/master --o--o--o--o--o--o--o


If you decide that now is the time to take feature_xyz into master you
will merge it in, using:
 git checkout master
 git pull
 git merge feature_xyz
 git push

At this point the branches will look like this:

 feature_xyz --o--o--o--o----o--o--o
                            /       \
 origin/master --o--o--o--o--o--o--o-o

(ie. there will be a new commit for the merge on master and master will
now contain both its own history prior to the merge, as well as the full
history of feature_xyz.  The final "git push" syncs origin/master with
master followin a successfull update of the remote))

Note that when using merge, you can actually continue working on
feature_xyz and make more merges from feature_xyz into master.

(If you use rebasing you have to be more careful about reusing the
branch)

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to