GIT Recipes

1) Make the current commit the only (initial) commit in a Git repository?

git checkout --orphan newBranch
git add -A
git commit -m "Initial Commit"
git branch -D master
git branch -m master #rename the mastyer
git push -f origin master
git gc --aggressive --prune=all

Another Way:
git init
git add *
git commit -m 'Initial commit'
git remote add origin [repo_address]
git push --mirror --force


2) Preventing push to upstream repository
A way to avoid pushing into a repository is providing a dummy url address to the repository.
This is accomplished by issuing the git command:
git remote set-url --push upstream no_push


3) To fix Git Detached head issue with master.
Mostly small steps like this will fix it
a)git reset --hard
b)git pull
c)git checkout master

src : https://stackoverflow.com/questions/10228760/fix-a-git-detached-head