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?

1
  • 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. Commented Mar 2, 2019 at 0:41

1 Answer 1

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.* )

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.