add file in initial commit without creating new commit

Viewed 418

I have made 10 commits and each commit have been already pushed to central repository. Lets suppose i have commits for example.

C1-C2-C3-C4-C5

where C5 was my last commit and all commits have been pushed. The branch i master. I want to delete the history and want to keep my last commit in git logs. I don't want anyone can reset head to any previous commit or push.

someone's told me to use git rebase -i head~4 but i want to make my sense clear, before implementing it.

I have implement following commands

git checkout --orphan newB
git add -A
git commit
git branch -D master
git branch -m master
git push

and after these above commands my git graph become as per given image below

git graph

Current graph of my repository is look like this

enter image description here

Look the first two commits and it is detached from master. And i want t go to the encircled hash. git rebase giving me following error

$ git rebase -i head~5
fatal: Needed a single revision
invalid upstream head~5
2 Answers
Related