How to completely reset a remote repository
Delete the .git directory locally
Recreate the git repostory
git init
touch .gitignore
git add .gitignore
git commit -m 'Initial commit'
Push to remote server, overwriting
git remote add origin <url>
git push --force origin master
How to create a new empty branch
Create a new empty branch named “your-new-branch”, clean up, add .gitignore and commit.
git symbolic-ref HEAD refs/heads/your-new-branch
rm .git/index
git clean -fdx
touch .gitignore
git add .gitignore
git commit -m 'Initial commit'
How to undo a push?
I wan to undo my last commit and push in branch master
$ git reset --hard HEAD^
HEAD is now at 539b80a CommitMessageGoesHere
$ git push -f origin 539b80a:master
How to undo a commit and redo? →
Here is how
git commit ...
$ git reset --soft HEAD^
$ edit
$ git commit -a -c ORIG_HEAD
Why aren't you using git-flow? →
Git extensions to provide high-level repository operations for Vincent Driessen’s branching model.
Git: How to checkout a tracked remote branch
git checkout --track -b <local branch> <remote>/<tracked branch>