-
Notifications
You must be signed in to change notification settings - Fork 0
git 💥
- remove all
git
history locally
rm -rf .git
- create a new local repo
git init
- add everything
git add .
git commit -m "initial commit"
- nuke history on GitHub (irreversible!) 💥
git remote add origin git@github.com:
USERNAME
/REPOSITORY
.gitgit push -u --force origin master
- add a
git ci --allow-empty
as first commit to a new repo so there is always the option to go back to the empty state? 💭
- As per Git Documentation:
The first commit made on an orphan branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits…
Ergo, this can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is “clean” (but whose full history contains proprietary or otherwise encumbered bits of code).
- Regardless, the strategy is: after you’ve created the orphan branch, you swap it out the with the “old” master:
- Create a new branch, with no parent commits
git checkout --orphan squashed-master master
git commit -m "prime commit"
- overwrite the old
master
branch with the new one…
git branch -M squashed-master master
- The
git
commit-tree
creates a new commit object based on the provided tree object and emits the new commit objectid
onstdout
… - The command below will create one commit object using
git commit-tree
and then reset theHEAD
to that commit:
git reset $(git commit-tree HEAD^{tree} -m "🎉 First commit")
- Since the git commit-tree method is a git one-liner, you can
alias
it:
git config --global alias.squash-all '!f(){ git reset $(git commit-tree HEAD^{tree} -m "${1:-prime commit}");};f'
- Thus, from thence on, you can just run
git squash-all
in any repo you please:
git squash-all
- Also check out this alias within ./freshinstall, an opinionated tool to automatically configure 🍏 MacOS (preferences, dotfiles, installed software, etc.)
- After rewriting history, you’ll need to use
--force
when pushing.
git push --force origin master…
nuke the history of a GitHub Wiki so that only the most recent revision of the Wiki’s content is available
# clone the Wiki…
git clone https://github.com/[user]/[repo].wiki.git
# remove the .git folder
rm -rf .git
# reconstruct the local repo with only latest content
git init
git add .
git commit -m "Initial commit"
# force push to GitHub
git remote add origin <github-uri>
git push -u --force origin master
This 📒
“documentum 📜 fragmenta”
🧩Wiki
offers supplemental guidance&documentation regarding some of what this project has to offer in terms of substantive code examples — in addition to assorted other hopefully useful or insightful references, tips, or otherwise informative snippets which in some way pertain to the craft of web‑development…