How to push new branch without history

前端 未结 3 1652
逝去的感伤
逝去的感伤 2020-12-22 16:54

I have git repo with two unrelated branches, master and configs. I\'ve created configs, purged all the files and then placed in configuration files only. Now I want to push

3条回答
  •  借酒劲吻你
    2020-12-22 17:56

    I needed to do this to send a freelancer some code without sharing private information or deleting my history.

    In case any of you are using SourceTree, this is how I managed to do it. Please let me know if I did something wrong or am forgetting something as I am very unfamiliar with source control management.

    1. I went to the terminal button on source tree.
    2. I created a new 'orphan' branch by using the command: 'git checkout --orphan clean-ver' where clean-ver is my branch name
    3. I closed the terminal and saw that my commit log was cleared because I was in a new orphan branch. I staged all my source code and committed the changes.
    4. I set up my bitbucket repository in either repository>add remote or repository>repository settings>add.
    5. I closed that, and clicked on the push button
    6. I selected my new 'clean-ver' branch said ok.

    When I checked bitbucket, it seems that this seemed to have worked and discarded my commit history.

    Hope this helps someone out.

提交回复
热议问题