2

I want to copy a git repository to another location so I can start working on a different project using that same code base. Is it enough to simply clone the repository and delete the .git folder and run git init or do I have to do some additional work?

Thanks in advance!

Cláudio Ribeiro
  • 1,509
  • 3
  • 37
  • 65
  • Possible duplicate of [Clone git repository without history?](https://stackoverflow.com/questions/30001304/clone-git-repository-without-history) – Chris Maes Jan 02 '19 at 10:05
  • Possible duplicate of [Copy a git repo without history](https://stackoverflow.com/questions/29368837/copy-a-git-repo-without-history) – phd Jan 02 '19 at 11:26
  • Not if you have sub-repositories or use git LFS – simpleuser Jan 25 '23 at 04:00

2 Answers2

4

If you only want to keep the working directory but delete all the git history, tags, branches, etc. you can just delete the .git directory and run git init ..

You may want to check also the local .gitignore and .gitattributes files if they exist, so that they conform to the new project needs.

rodrigo
  • 94,151
  • 12
  • 143
  • 190
3

Yes, deleting .git and git init will work. Also use git clone --depth 1 so you won't be downloading history, which you going to delete.