Mixaz
Mixaz

Reputation: 4178

fork git repo with clean history - will push work?

I'd like to fork a repo from github to bitbucket with clean history (I do not need and I want to save space). I found out that I can do it with git clone --depth 1 (shallow clone), but my question is if I'll be able to push updates from original repo to the new one?

Upvotes: 2

Views: 2017

Answers (1)

Mixaz
Mixaz

Reputation: 4178

I finally decided to go with other solution without git clone --depth 1 - I was not able to push shallow clone to a new repo on github. I understood that I used a wrong approach.

I created a new branch with no commit history as suggested here: Make the current commit the only (initial) commit in a Git repository?:

git branch new_branch_name $(echo "commit message" | git commit-tree HEAD^{tree})

and then I pushed it to the new repo as described in this excellent guide: How to fork a github repository in bitbucket:

$ git checkout new_branch_name
$ git remote add bb [email protected]:jcaraballo/test.git
$ git push -u bb new_branch_name

So now I have only one branch in the new repo with clean history, and I can exchange updates between the repos via branch new_branch_name, merging changes there.

Upvotes: 1

Related Questions