-1

I have very strange behavior: when run git clone from tcsh script for example:

git clone /my repo/ .

I get error: fatal: destination path '.' already exists and is not an empty directory.

The directory doesn't contain ".git".

if I run the same command after that from terminal it is ok.

version of git 1.9.3

I create this script from python.

I found problem. if I write "#" in line before for comment in tcsh script. Why is it ?

alex
  • 59
  • 5

1 Answers1

1

It's because . is a relative path. Try using a full path, it should work.

git clone myRepo /tmp/myDir should work better.

From: https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone

Cloning to a specific folder

git clone <repo> <directory>

Clone the repository located at <repo> into the folder called ~<directory>! on the local machine.

Community
  • 1
  • 1
Totoc1001
  • 338
  • 2
  • 11
  • What is toto ? I tried using full path but it wasn't work – alex Aug 17 '17 at 07:24
  • git clone my_repo /tmp/ does not work? Your script has got the exe rights? Chmod +x myScript – Totoc1001 Aug 17 '17 at 07:28
  • And also try using sh not tcsh just to check :) – Totoc1001 Aug 17 '17 at 07:34
  • I create this script from python. Maybe , this reason ? – alex Aug 17 '17 at 07:40
  • You can either shell out (via os.system or subprocess) or use the GitPython package then. Refer to: https://stackoverflow.com/questions/15079442/running-git-clone-command-in-python Or https://stackoverflow.com/questions/2472552/python-way-to-clone-a-git-repository – Totoc1001 Aug 17 '17 at 07:42
  • you don't understand me. I don't run git command from python. I create tcsh script from python with git commands – alex Aug 17 '17 at 07:51
  • 1
    Let me just try to sum up: you're in a python env or in a python script? From this python env you create a shell (tcsh) script and from there you try to perform a git clone. I'm right? If you try to execute your script outside of python does it work? And have you tried sh rather than tcsh? – Totoc1001 Aug 17 '17 at 07:57
  • I found problem. if I write "#" in line before for comment in tcsh script. Why is it ? – alex Aug 17 '17 at 08:57
  • What do you mean? The shebang? https://en.m.wikipedia.org/wiki/Shebang_(Unix) or # at beginning of a line? The shebang describes which shell should be use to execute the command. # starting a line means comment. – Totoc1001 Aug 17 '17 at 09:02
  • # at beginning of a line – alex Aug 17 '17 at 09:43
  • This mean it's a comment. So if your comment were not protected with #, they were executed, and that's why it did not work. But it's not related to git nor Python lol – Totoc1001 Aug 17 '17 at 10:13
  • If the answer satisfies you, can you please validate it? Thanks – Totoc1001 Aug 17 '17 at 10:14