2

I have the following git alias in my .gitconfig file.

    clone-with-branches = "!cloneWithBranches() { \
        git clone $1 $2 ; \
    }; cloneWithBranches"

I am supposed to use it as follows:

git clone-with-branches folder1 folder2

(supposing that folder1 is valid working git repository that is accessible with its relative path)

when in command line I type,

git clone folder1 folder2

I indeed obtain a clone of folder1 in folder2 but when I used the alias:

git clone-with-branches folder1 folder2

I obtain an error

fatal: repository 'folder1' does not exist.

Can anyone tell me what I missed please?

Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27
  • 2
    When you run `git clone-with-branches`, what directory ("folder", but **the full path name** is important) do you expect the `git clone` to be in when it is run? Note that aliases run from the top level of the work-tree. If that's not what you expect, search for the word `GIT_PREFIX` in the `git config` documentation. – torek Mar 02 '19 at 00:41

1 Answers1

1

Thanks Torek for the hint.
I modified the script as below and then the alias woks perfectly.

    clone-with-branches = "!cloneWithBranches() { \
        git clone $GIT_PREFIX$1 $GIT_PREFIX$2 ; \
    }; cloneWithBranches"

Please note that GIT_PREFIX is already set within Git and does not have to be set manually (cf http://schacon.github.io/git/git-config.html section alias.* )

Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27