美文网首页Git
Git remove commit history but ke

Git remove commit history but ke

作者: JaedenKil | 来源:发表于2019-08-16 17:03 被阅读0次

    Say I start a project, and make a lot of commits now and then, finally the project is OK to init, but the commit history is unnecessary.

    GitDemo (master)
    $ git log --oneline
    51fd1e8 (HEAD -> master) Add file03
    0c4bbec Add file02
    8e4c178 Add file01
    ---------------------------------------
    GitDemo (master)
    $ git checkout --orphan dev
    Switched to a new branch 'dev'
    ---------------------------------------
    GitDemo (dev)
    $ git reflog
    fatal: your current branch 'dev' does not have any commits yet
    ----------------------------------------
    GitDemo (dev)
    $ ls -al
    total 40
    drwxr-xr-x 1 zzheng 1049089 0 Aug 16 16:51 ./
    drwxr-xr-x 1 zzheng 1049089 0 Jul 24 18:04 ../
    drwxr-xr-x 1 zzheng 1049089 0 Aug 16 16:57 .git/
    -rw-r--r-- 1 zzheng 1049089 0 Aug 16 16:50 file01
    -rw-r--r-- 1 zzheng 1049089 0 Aug 16 16:51 file02
    --------------------------------------------
    GitDemo (dev)
    $ git status
    On branch dev
    
    No commits yet
    
    Changes to be committed:
      (use "git rm --cached <file>..." to unstage)
    
            new file:   file01
            new file:   file02
            new file:   file03
    ----------------------------------------------
    GitDemo (dev)
    $ git commit -m "Init project"
    [dev (root-commit) 924b8e0] Init project
     3 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 file01
     create mode 100644 file02
     create mode 100644 file03
    -----------------------------------------------
    GitDemo (dev)
    $ git branch -m master
    ------------------------------------------------
    git push -f origin master
    

    相关文章

      网友评论

        本文标题:Git remove commit history but ke

        本文链接:https://www.haomeiwen.com/subject/pwyqsctx.html