How to Undo the ‘init’ command on Git?
Git is a system which is used for tracking changes in the source code during application development. It is a form of version control in which the codebase for the application is mirrored on every developer’s computer. It allows the developers to coordinate the work amongst themselves and improves the integrity of the code while providing the ability to track all the changes made to the code.
The “git init” command is most usually the first command that a user runs on when starting a new project. This command allows the user to create a new Git repository. The command can be used to convert an old project into a Git Repository or to create a fresh repository. In this step, we will teach you the method to undo this command and reverse the changes made by this command.
How to Undo the “init” Command on Git?
In order to undo the effects of the “init” commands on the computer, we will be executing a command to delete the newly created git repository. Make sure that you execute the command accurately by following the indicated method. The Method differs slightly for Windows and Linux.
Method 1: For Linux
In this step, we will be undoing the changes made by the “init” command by deleting the git repository. For that, we will be executing a command in the terminal. In order to do that:
- Press “Ctrl” + “Alt” + “T” to open the terminal.
- Type in the following command and press “Enter”.
rm -rf .git
- This will delete the entire git repository and undo the changes made by the init command.
Method 2: For Windows
The method to undo the changes made by the init command for Windows differs slightly from the Linux one. Windows has a different command that can be executed in the command prompt to undo the changes. Therefore, in this step, we will be running the command prompt as administrator and executing the command. For that:
- Press “Windows” + “R” to open the Run prompt.
- Type in “cmd” and press “Shift” + “Ctrl” + “Enter” to provide administrative privileges.
- Type in the following command and press “Enter“.
rmdir .git
- If the repository has subfolders, type in the following command and press “Enter“.
rmdir /s .git
- This will undo the changes made by the “init” command.