1

I have a script that makes a clone of the repository I need. This script must be executed every day, i.e. reload data from the repository. There are no problems with cloning itself - the first launch downloads all the necessary files. But the next one knocks out this error.

stderr: 'fatal: destination path 'C:/Users/tred1/Desktop/WORK/анализатор/GHR_Y00011450/Data' already exists and is not an empty directory.

Those. I cannot clone a directory to a folder where it already exists. Which sounds pretty logical. I'm just learning how to work with git and sometimes I don't quite understand the commands.

Here is some of the code that does the cloning

class CloneProgress(RemoteProgress):
    def update(self, op_code, cur_count, max_count=None, message=''):
        pbar = tqdm(total=max_count)
        pbar.update(cur_count)

def save (source, directory):
    Repo.clone_from(source, directory,  branch='master', progress=CloneProgress())

How can I update and add new files from this directory to bypass this error? Maybe there is some method?

1
  • 2
    You should learn Git first Commented Aug 27, 2021 at 10:49

2 Answers 2

4

If you want to update an already cloned repo you do a pull

def save (source, directory):
    if not os.path.exists(directory):
        Repo.clone_from(source, directory,  branch='master', progress=CloneProgress())
    else:
        repo = Repo(directory)
        repo.remotes[0].pull()
Sign up to request clarification or add additional context in comments.

Comments

0

hm, I think it can help you Explanation

This is pretty vague but I'll do what I can to help.

First, while it may seem daunting at first, I suggest you learn how to do things from the command line (called terminal on OSX). This is a great way to make sure you're putting things where you really want to.

You should definitely google 'unix commands' to learn more, but here are a few important commands to help in this situation:

ls - list all files and directories (folders) in current directory

cd - change directory, or change the folder you're looking in

mkdir - Makes a new directory (be careful, you will have to cd into the directory after you make it)

rm -r - Removes a directory and everything inside it

git clone - Clones the repository into the directory you are currently browsing.

Answer

So, on my computer, I would run the following commands to create a directory (folder) called projects within my documents folder and clone a repo there.

Open terminal cd documents (Not case sensitive on mac) mkdir projects cd projects git clone https://github.com/seanbecker15/wherecanifindit.git cd wherecanifindit (if I want to go into the directory) p.s. wherecanifindit is just the name of my git repository, not a command!

1 Comment

now I'm trying to implement this process through a "remote.pull"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.