This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Rebasing local git branches on the new repo


On 1/13/20 6:00 AM, Jonathan Wakely wrote:
On Sun, 12 Jan 2020 at 18:08, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

Now that I've switched my local git tree to the new repo (by changing
the URL for the 'origin' remote, and adding the old one as a 'gcc-old'
remote) I've been experimenting with these commands to switch some of
the ~400 local branches to be based on the new repo instead of the
git-svn mirror.

       # The local branch to update
       branch=foo

       # The previous upstream for the branch
       upstream=$(git rev-parse --symbolic-full-name $branch@{u} | sed
-n s,^refs/heads,gcc-old,p)
       # find the last upstream commit in the branch
       base=$(git merge-base $branch $upstream)
       # extract its SVN revision
       svnrev=$(git log -1 $base | sed -n
'/git-svn-id:/s/.*@\([[:digit:]]\+\) .*/\1/p')
       # find equivalent commit in master
       onto=$(git log --pretty=format:%H --grep="From-SVN: r$svnrev" $branch@{u})

       git rebase --onto $onto $upstream $branch

Use at your own risk!

The attached script is a slightly more robust version of those commands.

Nice. I adjusted your script for my situation where I have a separate local repository for the new git (my old one is corrupt from unwise use of alternates), using format-patch/am for moving commits between them:

Attachment: copy_branch.sh
Description: application/shellscript


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]