git-submodule add -b

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

git-submodule add -b

Tim Olsen-3
The git-submodule man page says that the -b option to "git-submodule
add" is the "Branch of repository to add as submodule."

I get the error "fatal: A branch named '1.x' already exists." when I try
to use "git submodule add -b".  A sample session is below.  What am I
doing wrong?

tolsen@neurofunk:~/git$ mkdir submodule-branch
tolsen@neurofunk:~/git$ cd submodule-branch
tolsen@neurofunk:~/git/submodule-branch$ mkdir sub
tolsen@neurofunk:~/git/submodule-branch$ cd sub
tolsen@neurofunk:~/git/submodule-branch/sub$ git init
Initialized empty Git repository in
/home/tolsen/git/submodule-branch/sub/.git/
tolsen@neurofunk:~/git/submodule-branch/sub$ echo 1 > file
tolsen@neurofunk:~/git/submodule-branch/sub$ git add file
tolsen@neurofunk:~/git/submodule-branch/sub$ git commit -m v1
Created initial commit d5c185a: v1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file
tolsen@neurofunk:~/git/submodule-branch/sub$ echo 2 > file
tolsen@neurofunk:~/git/submodule-branch/sub$ git add file
tolsen@neurofunk:~/git/submodule-branch/sub$ git commit -m v2
Created commit fb864b2: v2
 1 files changed, 1 insertions(+), 1 deletions(-)
tolsen@neurofunk:~/git/submodule-branch/sub$ git log
commit fb864b2d4d9dacd87e55d0be970baa5fc6a0972c
Author: Tim Olsen <[hidden email]>
Date:   Fri Aug 1 16:21:09 2008 -0400

    v2

commit d5c185a7ea91b66b5df524b21bbe0daf40a456f4
Author: Tim Olsen <[hidden email]>
Date:   Fri Aug 1 16:21:03 2008 -0400

    v1
tolsen@neurofunk:~/git/submodule-branch/sub$ git checkout -b 1.x d5c185a7
Switched to a new branch "1.x"
tolsen@neurofunk:~/git/submodule-branch/sub$ echo 1.1 > file
tolsen@neurofunk:~/git/submodule-branch/sub$ git add file
tolsen@neurofunk:~/git/submodule-branch/sub$ git commit -m v1.1
Created commit d9868c5: v1.1
 1 files changed, 1 insertions(+), 1 deletions(-)
tolsen@neurofunk:~/git/submodule-branch/sub$ git log
commit d9868c5dc837404834b44eca6d21930c4f352127
Author: Tim Olsen <[hidden email]>
Date:   Fri Aug 1 16:21:58 2008 -0400

    v1.1

commit d5c185a7ea91b66b5df524b21bbe0daf40a456f4
Author: Tim Olsen <[hidden email]>
Date:   Fri Aug 1 16:21:03 2008 -0400

    v1
tolsen@neurofunk:~/git/submodule-branch/sub$ cd ..
tolsen@neurofunk:~/git/submodule-branch$ mkdir super
tolsen@neurofunk:~/git/submodule-branch$ cd super
tolsen@neurofunk:~/git/submodule-branch/super$ git init
Initialized empty Git repository in
/home/tolsen/git/submodule-branch/super/.git/
tolsen@neurofunk:~/git/submodule-branch/super$ echo dummy > dummy
tolsen@neurofunk:~/git/submodule-branch/super$ git add dummy
tolsen@neurofunk:~/git/submodule-branch/super$ git commit -m dummy
Created initial commit f1c41b6: dummy
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 dummy
tolsen@neurofunk:~/git/submodule-branch/super$ cd ..
tolsen@neurofunk:~/git/submodule-branch$ git clone super super2
Initialized empty Git repository in
/home/tolsen/git/submodule-branch/super2/.git/
tolsen@neurofunk:~/git/submodule-branch$ cd super2
tolsen@neurofunk:~/git/submodule-branch/super2$ git submodule add -b 1.x
~/git/submodule-branch/sub
Initialized empty Git repository in
/home/tolsen/git/submodule-branch/super2/sub/.git/
fatal: A branch named '1.x' already exists.
Unable to checkout submodule 'sub'
tolsen@neurofunk:~/git/submodule-branch/super2$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       sub/
nothing added to commit but untracked files present (use "git add" to track)
tolsen@neurofunk:~/git/submodule-branch/super2$

Thanks,
Tim

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html