Skip to content

Instantly share code, notes, and snippets.

@icodeforlove
icodeforlove / ScrollRestoration.tsx
Last active July 24, 2024 10:11
ScrollRestoration for React
'use client';
import { useEffect } from 'react';
function ScrollRestoration() {
useEffect(() => {
const pushState = history.pushState;
history.pushState = function (data, unused, url) {
const scrollY = window.scrollY;
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A