How to disable (stop, remove, delete) git versioning from a repository

Asked

Viewed 38,995 times

9

I cloned a Github repository in my directory, but it came full of commits, ie versioned. I wanted to restart it as a repository, from scratch, as I do?

I’ve tried the remote: git reset (didn’t work out).

What I want is the contrary to the command git init

  • you want to clone a repository but you want it to come without commits?

  • 2

    @athosbr99 I think Bruno wants to erase the history of the commits... honestly, I can’t imagine a situation where he wanted to do that. I always think it’s important to preserve the history.

  • I imagined doing this so that I could commit to Github as a newly initialized repository. Without the commits that came when I cloned someone else’s repository. There is @dcastro a better way to do this, or this is not good practice?

  • Is the repository you cloned also hosted on Github? If so, it’s best to "Fork" to get a copy of the repository

  • Either way, I think you should always keep track. You can always push the clone to github with the old history.

  • I know a former college professor who was asked to help find a bug in a company project. A task that should have lasted a day or two, it took weeks, because someone decided to erase the whole history and there was no way to find out when the bug was entered.

Show 1 more comment

5 answers

17


Delete the hidden folder .git within the repository and execute git init to start a new history.

7

I managed with the following command on linux/Ubuntu

rm -rf .git
  • git rm -Rf . git

  • 2

    I think this was the best solution, I do not know why it is not the right answer.

1

As already answered by dcastro, just remove the folder .git which is inside the repository. So you can start again.

If for some reason you don’t want to download a repository history when cloning it, use the --Depth flag as in the example:

git clone https://github.com/curl/curl.git --depth=1

-1

-2

With this command you can remove all the files Traced.

rm -rf .git 

On linux, it is no use to remove the folder .Git that the historical returns.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.