Git how to delete local repository
Git how to delete local repository
GitHub delete repository the RIGHT way [Step-by-Step]
Table of Contents
Brief workflow steps to delete Github repository
Deleting the Github repository is simple.
You can delete the directory containing the repo
navigate to the directory hosting the repo and run this command to Github delete repository on your command line.
The last step is to head over to the Github website and follow these to delete the target repository.
The above are typical routes to Github delete repository. What if you want to explore the nitty-gritty of deleting the Github repository?
That is why it would help to find practical ways to Github delete repository by following this tutorial to the end. Let us get started.
Lab setup to practice Github delete repository
We will imitate a typical development environment where you create a repo, clone it, make commits and push the changes to Github. We will then assume we no longer need the repo and delete it on the command line and Github.com.
I am creating a repo called github_delete_repo on Github.
Copy the repo URL.
Clone it on the command line.
Let us build the repo locally before seeing examples of the Github delete repository.
We currently have one commit history and a README.md file.
Let us create more files.
Stage the files
and commit them.
Repeat the process to create the third commit history.
Create two more files
Let us check the commit history.
We have three commits in the history.
Now that we have an active repo with some commits to practice the Github delete repository, let us apply the setup to the command line before remote repo deletion.
Github delete repository using the command line
Github delete repository on the command line starts by identifying the location of the target repo. For that reason, it would help to understand how a repository exists on your computer before deleting it.
How Github repository resides on your computer
The limit of interacting with instantiated repo depends on the git init flag used. For instance, instantiating an empty repo without a flag allows you to create a file, stage, and commit changes to the repo.
Common flags determining interaction with the local git repository
Running the command
makes git to ignore on the working directory when initializing the repo. The tracked files reside in the
template
separate
creates a text file with the path to the target directory.
quiet
to instantiate a quiet repo.
shared
you can specify user permissions for pushing or pulling changes to the repo. Examples of permissions to configure are TRUE, FALSE, GROUP, ALL, or EVERYBODY.
Now that you know how the repo resides on your computer, let us see two typical ways to delete it on the command line.
Delete the root directory
This is a dangerous route to take when doing Github delete repository on the command line because you cannot recover any files after the action.
Let us get out of the cloned Github repo.
and create another repo
then initialize it
Listing all files
Let us return to the root directory
Both repo and directory are gone!
Delete only the git sub-directory
Sometimes you need to delete a Github repo on the terminal or command line without clearing the files. Let us follow these steps to achieve that.
Check repo presence:
then run the following command to Github delete repository locally.
Recheck the repository.
The local version of the Github repository got deleted.
Method-2: Github delete repository from the website
Deleting a repo on the Github website is pretty straightforward. Follow these steps to achieve that.
Step-1. Move to github.com
Click the Sign in tab to access to your Github account.
You get to the Sign in page, permitting you to view all your repos.
Let us find the github_delete_repo repo we created earlier among the list of repos.
Step-2. Access the main page of the target repo
Click on the target repo. We land on a repo’s page appearing, as follows:
Step-3. Click Settings on the navigation menu
Click the highlighted Settings tab, as shown here.
Step-4. Scroll down until you see Danger Zone
You should the Change repository visibility, Transfer ownership, Archive this repository, and Delete this repository buttons.
Step-5. Click on Delete this repository
Step-6. Type the repo name and accept the warnings
Github redirects us to the main page with a success message, Your repository «Stevealila/github_delete_repo» was successfully deleted.
Conclusion
Related Posts
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
Работаем с репозиториями в Git
Одна из самых распространенных систем управления версиями – Git. Ее ядро добавляет в систему ряд консольных команд, предназначенных для управления репозиториями. В самих же репозиториях хранятся важные каталоги, конфигурационные файлы, журналы и прочие связанные элементы.
Далее я расскажу, как создать, клонировать и удалить эти репозитории.
Следующие инструкции предназначены для тех, кто уже установил Git на свой сервер. Если вы еще не сделали этого, используйте руководство с GitHub, которое поможет разобраться с выполнением поставленной задачи.
Создание Git-репозитория
Сначала рассмотрим создание репозитория. Представим, что у вас уже есть папка для хранения файлов, но она еще не находится под контролем Git.
Откройте «Командную строку» (Windows) или Терминал (Linux/macOS) и перейдите по пути данной папки.
В Linux выполните команду:
В macOS :
В Windows:
Остается только ввести нижеуказанную команду, чтобы завершить первый этап.
Теперь у вас есть Git-репозиторий со всеми необходимыми составляющими и отслеживаемыми файлами.
Клонирование существующего репозитория
При использовании упомянутой команды вы получаете клоны всех версий файлов, а значит, можете использовать любые из них, если что-то пойдет не так. Это же пригождается, когда требуется вернуть предыдущую версию проекта, что осуществимо благодаря файлам, помещенным под версионный контроль.
При использовании вышеуказанной команды репозиторий клонируется с текущим названием. Если же оно должно отличаться, используйте следующую вариацию команды:
Завершим этот раздел статьи описанием содержимого, которое появляется в консоли при выполнении команды. Данный вывод соответствует успешному клонированию:
Удаление локального Git-репозитория
Если с созданием и клонированием репозиториев все понятно, то как быть, когда папка с проектом уже существует, но в нее нужно поместить новые данные, удалив предыдущие, или когда Git-репозиторий на сервере больше не нужен. В таком случае осуществляется стандартное удаление.
В корне каталога с проектом необходимо избавиться от папки .git, о которой уже шла речь выше. Так вы удаляете только ту информацию, которая связана с Git, но сам проект остается. В Linux через Терминал вы должны перейти к каталогу с проектом и ввести следующую команду:
Еще один вариант – удаление .gitignore и .gitmodules в случае их наличия. Тогда команда меняет свой вид на:
Только что мы разобрались с основами создания, клонирования и удаления Git-репозитория. Удачи!
Deleting a Local GitHub Repository
If you want to delete a local Github Repository that was cloned from to local computer without touching or making any changes to the Remote GitHub repository then follow the commands below:
Step 1: Go into your project file
With the deletion of the ‘.git’ file, this will delete the .git file that contains a log of the commit history, its information, and also remote repository address from the working directory. We can think of this deletion as when we do git init to initialize the current working directory as Git directory, with the above command we are just reverting it back to not being a Git directory.
Then what about the files and folder in the present working directory?
This has to be deleted using the following set of command:
Step 2: (Optional if you want to initialize working directory to another GitHub Repository See Additional steps below):-
Go to the directory where the project is present (Note: Don’t go inside the project file).
What are rm and rf commands?
Additional Steps:
Suppose you want to initialize (git init) a new Github repository, and then add it to a new remote repository and then start adding and committing to the files being added from the current working directory.
Deleting the Repository from GitHub Website
Step 1: Navigate to your project
Step 2: Go to the settings option on the top right corner like the image above, and navigate down to the danger zone
Step 3: Go and click on the delete this repository button and after which you will be prompted to make sure you are deleting and all these action will permanently affect the repository, in the box type your-username/project-name (replace it with yours).
You may also be prompted to type in the GitHub password.
Following these steps will make sure you have completely deleted the repository from the local PC as well as the GitHub site.
Deleting the File from GitHub Website
Step 1: Navigate to your project
Step 2 : Browse to the file in your repository that you want to delete.
At the top of the file, click on the Delete Icon.
Step 3: At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file
Then it will show a alert like this that the File successfully deleted.
How to delete a Gitlab repository
Part of GitLab Collective
I have googled a while now and could not find a solution that fits the current UI of Gitlab. I am trying to remove a repository I previously created on Gitlab. I navigate to edit project by clicking the settings cog on the right. After scrolling down to the bottom I can not find a section called remove project. Instead, I only see rename project. I should have the proper rights because I am the master of the project.
6 Answers 6
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Go to Settings > Expand Advanced Settings > Remove Project
It seems like master privilege is not sufficient. An owner privilege is required to perform such actions.
(Most) of the other answers work.
But: When you are are running a self-hosted gitlab they are not complete.
The repo will not deleted, but only marked as deleted and hidden.
The full solution:
(This is for gitlab 14.8.4, other versions might have some tiny differences)
First let the site forget about it:
Gitlab will mark it as deleted and after a couple of minutes a part, but not everything, will be «really» deleted.
After waiting a couple of minutes delete everything that has not been completely deleted:
How to Delete a Repository in GitHub
GitHub is a popular option for showcasing your projects online, and creating new repositories for side projects can get pretty addictive. If you find yourself with one-too-many repositories in your account and you want to simplify your profile, read on to learn how to delete a repository in GitHub.
Warnings About Deleting a Repository in GitHub
You can delete any repository or fork if you’re the organization owner or if you have admin permissions for that repository or fork. A couple things to keep in mind, though:
Deleting a fork does not have any effect on the upstream repository. Deleting a private repository will delete all associated forks, but deleting a public repository will not have any effect on the forks.
Deleting a repository will remove all wikis, issues, and comments associated with the repository. Once deleted, there is no way to restore a repository. Don’t say we didn’t warn you.
How to Delete a Repository in GitHub
To start the deletion process, open GitHub, and log in to your account.
Click on your profile icon from the top-right, and select Your repositories.
From this page, find the repository you want to delete, and click on the title. Then, locate the toolbar at the top and click the Settings tab.
Scroll all the way to the bottom of the page until you see the Danger Zone section. Here, click Delete this repository.
You’ll now see a pop up asking if you’re sure you want to delete the repository. Enter the name of the repository in the text box and click the I understand the consequences, delete this repository button.
If you’re not sure about deleting all data, you can try archiving the repository instead. From the same Danger Zone section, select Archive this repository. This will put the repository into a read-only mode, but other users will still be able to fork it. You can then always go back to the repository’s settings page and click on Unarchive this repository to bring it back to life.
Once you delete the repository, you’ll be back on the GitHub home page, and a banner at the top will inform you that the repository was successfully deleted.
Want to learn more about GitHub? Check out our GitHub overview for tutorials and ways to integrate GitHub with 1,500+ other apps.
Get productivity tips delivered straight to your inbox
We’ll email you 1-3 times per week—and never share your information.
Khamosh Pathak is a technology writer specializing in simplifying consumer technology for the everyday user. He’s on a mission to help users get the most out of their technology products, whether it’s hardware or software.