Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up deleted repo's? #54

Open
Shooter3k opened this issue Sep 23, 2019 · 6 comments
Open

clean up deleted repo's? #54

Shooter3k opened this issue Sep 23, 2019 · 6 comments

Comments

@Shooter3k
Copy link

Is there any way to have this automatically delete repositories that no longer exist?

Example of current:

git_checkout:
    Fetching origin: error: Could not read from remote repository. Please ma

ke sure you have the correct access rights and the repository exists.
Updating master: up to date.

@earwig
Copy link
Owner

earwig commented Sep 24, 2019

There's nothing built-in to do this, and it seems a bit dangerous to add because a temporary issue with the remote (like a permissions issue) would cause your local copy to get deleted. You also need to consider situations with multiple remotes or when we have branches out of sync with the remote we can't update. Basically, I'm not sure what a "safe" check for this would look like.

@Shooter3k
Copy link
Author

Maybe I'm not using this application for it's intended purpose? At my work, we have around 500 repos. With that many, they get moved or deleted fairly often and the only way for me to fix it is to find them by hand and manually delete them.

Do you have any suggestions for how I can remove these deleted repos?

@earwig
Copy link
Owner

earwig commented Sep 26, 2019

Something like this will work:

gitup . -e 'bash -c "git ls-remote --exit-code >/dev/null 2>&1 || (rm -rf $(git rev-parse --show-toplevel) && echo deleted)"'

Just keep in mind that it's inherently very dangerous if you are ever unable to access the remote for some reason.

@Xaelias
Copy link

Xaelias commented Sep 26, 2019

At the very least you can check that the remote server answers on port 22 or 443 (depending on if you use ssh or https) by grepping the config in .git and testing with nc. Just to make sure it's not just the server being offline.
But if you want to try and get all the edge cases (ssh key not in the keychain/agent anymore, temporary access issue, etc. etc.) it's going to be real hard.
Also it doesn't sound fun working at a company that things having 500 git repos is a good idea :-D
You could have a process that "quarantine" these repos. Move them to a secondary folder you can recover them from. And then have a cron job that deletes them after x days based on mtime.

@Shooter3k
Copy link
Author

Ha. That's a creative approach. Thank you. I'm currently running gitup on a Windows machine so I'll install it on a unix machine and give this a shot. Thanks for taking the time to answer the question.

Something like this will work:

gitup . -e 'bash -c "git ls-remote --exit-code >/dev/null 2>&1 || (rm -rf $(git rev-parse --show-toplevel) && echo deleted)"'

Just keep in mind that it's inherently very dangerous if you are ever unable to access the remote for some reason.

@jrcastine
Copy link

gitup -n will clean up it's bookmarks file for repo's that are no longer there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants