简体   繁体   English

Git Clone,删除GitHub存储库,创建新存储库->仍然有提交历史记录吗?

[英]Git Clone, Delete the GitHub Repo, create new repo-->still have commit history?

I'm a newbie to git, and was hoping to delete a particular GitHub repository (from public view purposes). 我是git的新手,并且希望删除特定的GitHub存储库(出于公共目的)。 However, I'd like to keep a "copy" on my local computer with all its previous commits. 但是,我想在本地计算机上保存所有先前提交的“副本”。 If I git clone the repo, delete the repo on GitHub, then create a new repo, and finally push the local cloned project to the new repo, will the new repo have my commit history? 如果我git复制存储库,请在GitHub上删除存储库,然后创建一个新存储库,最后将本地克隆的项目推送到新存储库,新存储库是否有我的提交历史记录? Is this because the commit history is "stored" in my local project? 这是因为提交历史记录已“存储”在我的本地项目中吗?

Thanks! 谢谢!

Yes, it will still have the history, as the entire repo (which includes the history) is pushed. 是的,当推送整个仓库(包括历史记录)时,它仍将具有历史记录。

If you want to create a version of the repo without the history, do the following: 如果要创建没有历史记录的版本库,请执行以下操作:

  1. Make a copy of your directory to, say, newdir 将目录复制到newdir
  2. Delete newdir/.git 删除newdir / .git
  3. In newdir, type git init . 在newdir中,输入git init .
  4. Still in newdir, type git add . 仍然在newdir中,输入git add .

Now newdir will contain a repo with just a single commit, which contains the latest from your repository, and you can push that . 现在,newdir将仅包含一个提交就包含一个存储库,其中包含来自存储库的最新提交,您可以将推送。

Yes, the new repo will still have your commit history. 是的,新的仓库仍将保留您的提交历史记录。 When you "clone" a repo, you are cloning ALL aspects of it, which include commit history. 当您“克隆”一个仓库时,您正在克隆它的所有方面,包括提交历史。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有什么方法可以删除github仓库中的提交历史吗? - is there some method to delete the commit history in the github repo? Git 克隆到 repo 作为提交 - Git clone into repo as commit 从git repo克隆并提交到新的存储库 - clone from a git repo and commit to a new repository 将Git repo克隆到新的repo中 - 没有提交历史记录 - Cloning a Git repo into a new repo - without commit history 重写Git回购历史记录后,旧的提交历史记录仍然可见 - After rewriting Git repo history, the old commit history is still visible git提交到github repo - git commit to github repo 将几个github仓库迁移到一个仓库,并仍然保留提交历史 - migrate several github repos to one repo and still preserve the commit history 提交 git repo 的根提交(删除历史记录) - Make a commit the root commit of a git repo (Delete history) 如何创建一个新的 git 回购,其第一次提交是源的最后一次提交(没有历史,没有链接到源回购,只有主分支) - how create a new git repo whose first commit is the last commit of the source (no history, not linked to source repo, and only the master branch) 克隆没有历史记录的git仓库,并让原始仓库能够将更改推送到浅仓库 - Clone a git repo without history and have the original repo be able to push changes to the shallow repo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM