question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Files already exist in <location> when migrating a repo.

See original GitHub issue

Ok, back again 😃

I was able to get copybara working using the copybara repo, and now I’m switching over to the @sonatype repo I want to migrate to a public one.

I’m running copybara copy.bara.sky --force

My copy.bara.sky looks like:

url = "git@github.com:sonatype/INTERNAL_REPO.git"

core.workflow(
    name = "default",
    origin = git.origin(
        url = url,
        ref = "master",
    ),
    destination = git.destination(
        url = "file:///tmp/foo",
        fetch = "master",
        push = "master",
    ),
    destination_files = glob(["matthew/py-iq-reports/IQreport/**"], exclude = ["README_INTERNAL.txt"]),

    authoring = authoring.pass_thru("Jeffry Hesse <jeffryxtron@gmail.com>"),
    transformations = [
	    core.move("", ""),
	],
)

I end up with this:

764 jeffryhesse:IQreport (master *)$ copybara copy.bara.sky --force
Copybara source mover (Version: Unknown version)
Task: Git Origin: Initializing local repo
Enter passphrase for key '/Users/jeffryhesse/.ssh/id_rsa': 
WARN: Cannot find last imported revision, but proceeding because of --force flag
Task: Moving 
ERROR: Files already exist in /Users/jeffryhesse/copybara/temp/workdir2564596437170999916/checkout:

I’ve truncated the filelist since it’s a lot of internal stuff, plus likely not going to give much actual detail on the issue. I’m not sure what’s quite going on here, and I’m sure I’m missing something. Any help is appreciated.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mikelalconcommented, Jul 6, 2017

No problem at all 😃. We should improve the documentation.

Let me write here a short example for now:

Lets say we want to move ‘public’ folder from git.origin but we don’t want to export ‘public/SECRET.txt’

origin_files would be:

origin_files = glob([“public/**”], exclude = [“public/SECRET.txt”])

Note that we exclude public/SECRET.txt and not just SECRET.txt. This is because the include part can contain multiple folders.

Now lets say we want to move everything to the root of the destination:

transformations = [ core.move(“public”, “”) ]

Now lets say we have in the destination a README.txt file that we don’t want to delete:

destination_files= glob([“**”], exclude = [“README.txt”])

Now lets say that instead we want to keep it in the ‘public’ folder in the destination. You would not include any transformations (You can skip transformations = …) and instead you would write the following destinations_files:

destination_files= glob([“public/**”], exclude = [“public/README.txt”])

Or if you don’t have a README.txt inside public:

destination_files= glob([“**”])

0reactions
kopporcommented, Dec 22, 2020

I came here by googling for that error message. My solution was to use overwrite=True. Just in case someone else comes here and is as impatient as me when reading the move reference:

transformations = [
    core.move("README-public.md", "README.md", overwrite=True)
],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Target location for project " " already exists, can not move project
Goto your Git repo in the file system and paste the project folder at the location you want (may be inside another folder...
Read more >
Moving a file to a new location - GitHub Docs
On your computer, move the file to a new location within the directory that was created locally on your computer when you cloned...
Read more >
Remote Origin Already Exists Error: How To Fix It | CloudBees
Go to your local repository and remove the existing origin remote. Add the new online repository as the correct origin remote. Push your...
Read more >
How to move a git repository with history | Atlassian Git Tutorial
1. Create a local repository in the temp-dir directory using: · 2. Go into the temp-dir directory. · 3. To see a list...
Read more >
Migrating to a new Git repository | Looker - Google Cloud
Now, to bring in history and files for dev branches, you'll need to do git checkout dev_branch_name and git push origin for each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found