Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Clear local and remote repo and start over

Tags:

git

github

I accidentally got a repo in a bad state when trying to move a project from using ant to maven. Now, I would like to clear the repo and startover from scratch. Being new to git, I am a little cautious and not sure if I could just checkout then delete all files and folders locally then push to the remote repo or if that was actually a very bad idea. For some reason I'm having a hard time asking the correct questions in google. :D

like image 829
RockyMountainHigh Avatar asked Mar 28 '13 14:03

RockyMountainHigh


People also ask

How do I completely reset Git?

To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on).

How do I restart a git repository?

If you want to restart a git repo, nuke the . git directory and do git init add your files/directories and commit.

How do I delete everything from my repository?

In order to delete files recursively on Git, you have to use the “git rm” command with the “-r” option for recursive and specify the list of files to be deleted. This is particularly handy when you need to delete an entire directory or a subset of files inside a directory.

Can I just delete a local Git repository?

In order to delete a local GitHub repository, use the “rm -rf” on the “. git” file located at the root of your Git repository. By deleting the “. git” file, you will delete the Github repository but you won't delete the files that are located in your project folder.

How do I hard reset the remote Git repository?

Performing a hard reset of the remote repository is quite easy. After you've reset the local repository, simply do a force push with the follow git command: In the example we used above, that git command would look like this:

What happens when you clone a git repository from another Repo?

When a user clones a Git repository from Github using the command git clone <url>, they get a copy of the remote repo on their local computer so that they can work on it on their current working directory where the repo got cloned without directly making changes on the remote repository.

How do I remove a git repository from a folder?

rm -rf <repository_folder>.git 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.

Is it possible to reset to a local commit in Git?

You can reset to a local commit instead of origin/master, but most of the time you’ll be resetting to the state of the remote. However, git reset is usually not enough. Resetting in Git only resets files that are actually tracked by Git. This includes code and resources that receive changes.


1 Answers

Simply remove local .git directory, remove repo from server (if it is github - do Repo -> setiings -> remove).

Then create new repository on server, and locally do:

git init git remote add origin [email protected]:user/project.git git add . git commit -m "Initial commit" git push -u origin master 
like image 124
Ruslan Osipov Avatar answered Sep 18 '22 09:09

Ruslan Osipov