lawrence
lawrence

Reputation: 353

Push existing repository to another repository

I have an existing .git project and have many commit message logs.I want to push this project to github.com, after doing that, I found that the commit logs also be pushed. How could I can push the existing project to github.com without old commit log?

Upvotes: 1

Views: 154

Answers (2)

Vampire
Vampire

Reputation: 38619

Create a new orphan branch (branch without history) with git checkout --orphan new-master && git add . && git commit -m "initial commit", then force-push this new branch without history to github with git push -f origin new-master:master or rename your local branches previously like git branch -m master old-master && git branch -m new-master master and just force-push.

Upvotes: 0

blue112
blue112

Reputation: 56412

Create a new repository:

git init new_repo

Copy every file in the repository, using, for instance :

cd old_repos
cp -r * ../new_repo

Commit and push everything

git add .
git commit -m "Initial commit"
git remote origin add github:myrepo
git push origin/master

Upvotes: 2

Related Questions