Git
Clean history
Without submodules
cd reporm -rf .gitgit init -b mastergit add .git commit -m "Initial commit"git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPO>.gitgit push -u --force origin master
With submodules
git checkout --orphan newBranchgit add -Aadd all files and commit themgit commitgit branch -D masterdelete the master branchgit branch -m masterrename the current branch to mastergit push -f origin masterforce push master branchgit gc --aggressive --prune=allremove the old files
Untrack files already added to git repository based on .gitignore
- commit and push all
git rm -r --cached .rmis the remove command-rwill allow recursive removal–cachedwill only remove files from the index. Your files will still be there.- The
.indicates that all files will be untracked. You can untrack a specific file withgit rm --cached foo.txt
git commit -m ".gitignore fix"- push
Everything about .gitignore
https://www.atlassian.com/git/tutorials/saving-changes/gitignore
Remove unpushed commit
Delete the most recent commit:
git reset --hard HEAD~1
Delete the most recent commit, without destroying the work you’ve done:
git reset --soft HEAD~1