threads / discuss / 14872

git svn rebase - could not detach HEAD

Subject: git svn rebase - could not detach HEAD

## tl;dr

7 messages between Aug 7, 2008 and Aug 7, 2008.

replies: 6people: 4as markdown or json

Tony Stubbs· Aug 7, 2008, 06:49 UTC · lore
Having trouble rebasing against svn off a clean repo.
I am using windows / cygwin.
Here's the output:

stubbsa@VFNZV95336 /cygdrive/c/dev $ git status # On branch master nothing to commit (working directory clean)

stubbsa@VFNZV95336 /cygdrive/c/dev $ git svn rebase First, rewinding head to replay your work on top of it... could not detach HEAD rebase refs/remotes/git-svn: command returned error: 1

stubbsa@VFNZV95336 /cygdrive/c/dev $

I already tried asking on the channel... Any ideas? I'm kind of stuck as I have commits I need to dcommit.

p.s. git stash also shows: stubbsa@VFNZV95336 /cygdrive/c/dev $ git stash No local changes to save

Tony Stubbs· Aug 7, 2008, 07:19 UTC · re: Tony Stubbs · lore

Re: git svn rebase - could not detach HEAD

Some more info...:

stubbsa@VFNZV95336 /cygdrive/c/dev $ git merge-base HEAD git-svn 5bfad5dee44fd18f7c3a39e7dcb234828c840c24

commit 5bfad5dee44fd18f7c3a39e7dcb234828c840c24
Author: boses <boses@c07779a9-5238-0410-8e60-f4d13a72d009>
Date:   Thu Aug 7 01:28:44 2008 +0000
    Siebel Java Interface Merged
    git-svn-id:
http://10.107.6.150/repos/portal/oasis/branches/oasis-cr@3273
c07779a9-5238-0410-8e60-f4d13a72d009
$ git branch -a
  emailTemplateWork
  hibernate
  integration
* master
  git-svn
  git-svn@1775
  git-svn@2473
  laptop/emailTemplateWork
  laptop/hibernate
  laptop/master
  temp/master

stubbsa@VFNZV95336 /cygdrive/c/dev $ git checkout hibernate Switched to branch "hibernate"

stubbsa@VFNZV95336 /cygdrive/c/dev $ git checkout master Checking out files: 100% (295/295), done. Switched to branch "master"

stubbsa@VFNZV95336 /cygdrive/c/dev $ git svn rebase First, rewinding head to replay your work on top of it... could not detach HEAD rebase refs/remotes/git-svn: command returned error: 1

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase fatal: Needed a single revision invalid upstream

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase git-svn First, rewinding head to replay your work on top of it... could not detach HEAD

2008/8/7 Tony Stubbs <antony.stubbs@gmail.com>:
Show 29 quoted lines
> Having trouble rebasing against svn off a clean repo.
>
> I am using windows / cygwin.
>
> Here's the output:
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git status
> # On branch master
> nothing to commit (working directory clean)
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git svn rebase
> First, rewinding head to replay your work on top of it...
> could not detach HEAD
> rebase refs/remotes/git-svn: command returned error: 1
>
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $
>
> I already tried asking on the channel...
> Any ideas? I'm kind of stuck as I have commits I need to dcommit.
>
> p.s. git stash also shows:
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git stash
> No local changes to save
>
-- 
___________________________
http://stubbisms.wordpress.com/
Junio C Hamano· Aug 7, 2008, 07:20 UTC · re: Tony Stubbs · lore

Re: git svn rebase - could not detach HEAD

"Tony Stubbs" <antony.stubbs@gmail.com> writes:
> $ git svn rebase
> First, rewinding head to replay your work on top of it...
> could not detach HEAD
> rebase refs/remotes/git-svn: command returned error: 1

It is somewhat unfortunate that git-svn does not say anything about what ref it is trying to rebase onto here. I do not use git-svn nor know much about the code myself, but here are some ideas.

 * Try "rebase --dry-run" and see what you see from this part of the code:
        sub cmd_rebase {
                ...
                if ($_dry_run) {
                        print "Remote Branch: " . $gs->refname . "\n";
                        print "SVN URL: " . $url . "\n";
                        return;
                }
   Most interesting is what $gs->refname is;
 * If you are using recent enough git (I think 1.5.2 is Ok), update your
   copy of git-rebase like this, so that you would at least see *why* you
   cannot detach HEAD.  It is possible that git-svn is giving a nonsense
   ref to detach to.
diff --git a/git-rebase.sh b/git-rebase.sh
index e2d85ee..7825f88 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -376,9 +376,7 @@ fi
 
 # Detach HEAD and reset the tree
 echo "First, rewinding head to replay your work on top of it..."
-git checkout "$onto^0" >/dev/null 2>&1 ||
-	die "could not detach HEAD"
-# git reset --hard "$onto^0"
+git checkout -q "$onto^0" || die "could not detach HEAD"
 
 # If the $onto is a proper descendant of the tip of the branch, then
 # we just fast forwarded.
Tony Stubbs· Aug 7, 2008, 07:33 UTC · re: Junio C Hamano · lore

Re: git svn rebase - could not detach HEAD

Ok, woah. that's really weird... note the strange behaviour of git-clean (i had my ide open, then clossed it. but it still acted strange)

that seems to have got it. so are you going to apply that patch to git proper?

stubbsa@VFNZV95336 /cygdrive/c/dev $ git --version git version 1.5.6.4

stubbsa@VFNZV95336 /cygdrive/c/dev $ git svn rebase --dry-run Remote Branch: refs/remotes/git-svn SVN URL: http://10.107.6.150/repos/portal/oasis/branches/oasis-cr

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase git-svn First, rewinding head to replay your work on top of it... error: Untracked working tree file 'webnonline-db-access/target/hanson-db-access-1.0.jar' would be overwritten by merge. could not detach HEAD

stubbsa@VFNZV95336 /cygdrive/c/dev $ git clean -df Removing .temp/ Removing Libraries/release/ Removing SiebelJavaInterface/release/ Removing SiebelJavaInterface/src/generated/ Removing SiebelJavaInterface/tmp/ Removing Utilities/.apt_src/ Removing Utilities/build/ Removing VFSecurityProviders/build/ Removing VFSecurityProviders/vfSecurityProviders.jar Removing VFSecurityProviders/vfSecurityProviders_r1_00_01.jar

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase git-svn First, rewinding head to replay your work on top of it... error: Untracked working tree file 'webnonline-db-access/target/hanson-db-access-1.0.jar' would be overwritten by merge. could not detach HEAD

stubbsa@VFNZV95336 /cygdrive/c/dev $ git clean -df Removing Utilities/.apt_src/ Removing Utilities/build/

stubbsa@VFNZV95336 /cygdrive/c/dev $ git clean -df Removing Utilities/.apt_src/ Removing Utilities/build/

stubbsa@VFNZV95336 /cygdrive/c/dev $ git clean -df

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase git-svn First, rewinding head to replay your work on top of it... error: Untracked working tree file 'webnonline-db-access/target/hanson-db-access-1.0.jar' would be overwritten by merge. could not detach HEAD

<manually deleted "untracked file" here>

stubbsa@VFNZV95336 /cygdrive/c/dev $ git rebase git-svn First, rewinding head to replay your work on top of it... Applying removed generated files Applying Changed maven call method Applying Switched dependency to project from jar Applying Added dependency build Applying Updated notification service build target

2008/8/7 Junio C Hamano <gitster@pobox.com>:
Show 44 quoted lines
> "Tony Stubbs" <antony.stubbs@gmail.com> writes:
>
>> $ git svn rebase
>> First, rewinding head to replay your work on top of it...
>> could not detach HEAD
>> rebase refs/remotes/git-svn: command returned error: 1
>
> It is somewhat unfortunate that git-svn does not say anything about what
> ref it is trying to rebase onto here.  I do not use git-svn nor know much
> about the code myself, but here are some ideas.
>
>  * Try "rebase --dry-run" and see what you see from this part of the code:
>
>        sub cmd_rebase {
>                ...
>                if ($_dry_run) {
>                        print "Remote Branch: " . $gs->refname . "\n";
>                        print "SVN URL: " . $url . "\n";
>                        return;
>                }
>
>   Most interesting is what $gs->refname is;
>
>  * If you are using recent enough git (I think 1.5.2 is Ok), update your
>   copy of git-rebase like this, so that you would at least see *why* you
>   cannot detach HEAD.  It is possible that git-svn is giving a nonsense
>   ref to detach to.
>
> diff --git a/git-rebase.sh b/git-rebase.sh
> index e2d85ee..7825f88 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -376,9 +376,7 @@ fi
>
>  # Detach HEAD and reset the tree
>  echo "First, rewinding head to replay your work on top of it..."
> -git checkout "$onto^0" >/dev/null 2>&1 ||
> -       die "could not detach HEAD"
> -# git reset --hard "$onto^0"
> +git checkout -q "$onto^0" || die "could not detach HEAD"
>
>  # If the $onto is a proper descendant of the tip of the branch, then
>  # we just fast forwarded.
>
-- 
___________________________
http://stubbisms.wordpress.com/
Björn Steinbrink· Aug 7, 2008, 07:41 UTC · re: Tony Stubbs · lore

Re: git svn rebase - could not detach HEAD

On 2008.08.07 19:33:36 +1200, Tony Stubbs wrote:
Show 5 quoted lines
> Ok, woah. that's really weird... note the strange behaviour of
> git-clean (i had my ide open, then clossed it. but it still acted
> strange)
> 
> that seems to have got it. so are you going to apply that patch to git proper?
It already is.
Show 17 quoted lines
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git clean -df
> Removing Utilities/.apt_src/
> Removing Utilities/build/
> 
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git clean -df
> 
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git rebase git-svn
> First, rewinding head to replay your work on top of it...
> error: Untracked working tree file
> 'webnonline-db-access/target/hanson-db-access-1.0.jar' would be
> overwritten by merge.
> could not detach HEAD
> 
> <manually deleted "untracked file" here>

Maybe you're ignoring that file? git clean deletes ignored files only if you use -x/-X.

Björn
Tony Stubbs· Aug 7, 2008, 12:53 UTC · re: Björn Steinbrink · lore

Re: git svn rebase - could not detach HEAD

2008/8/7 Björn Steinbrink <B.Steinbrink@gmx.de>:
>> that seems to have got it. so are you going to apply that patch to git proper?
>
> It already is.
Great!
Show 7 quoted lines
>> <manually deleted "untracked file" here>
>
> Maybe you're ignoring that file? git clean deletes ignored files only if
> you use -x/-X.
>
> Björn
>

That's probably it, I'll try it tomorrow. However, that could be a problem. There's ignored files I don't want to keep (build artifacts), and there's ignored files I do want to keep (i.e. .metadata). Is there a good solution?

-- 
___________________________
http://stubbisms.wordpress.com/
Daniel Barkalow· Aug 7, 2008, 14:24 UTC · re: Tony Stubbs · lore

Re: git svn rebase - could not detach HEAD

On Fri, 8 Aug 2008, Tony Stubbs wrote:
Show 12 quoted lines
> >> <manually deleted "untracked file" here>
> >
> > Maybe you're ignoring that file? git clean deletes ignored files only if
> > you use -x/-X.
> >
> > Björn
> >
> 
> That's probably it, I'll try it tomorrow. However, that could be a
> problem. There's ignored files I don't want to keep (build artifacts),
> and there's ignored files I do want to keep (i.e. .metadata).
> Is there a good solution?

There's only a problem if there's some reason you specifically want to not keep an ignored file; this is usually only an issue when you're trying to merge/rebase with a branch that has it tracked, at which point you have to decide whether to add your version and merge or remove your version. Ideally, git would tell you when the file that's in the way is ignored, which would probably help you know what's going on, but it's tricky to get that information there.

	-Daniel
*This .sig left intentionally blank*

← back to recent threads