Skip to content

Instantly share code, notes, and snippets.

@e93Ym0WnIO
e93Ym0WnIO / revert-a-commit.md
Created February 8, 2023 07:45 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@e93Ym0WnIO
e93Ym0WnIO / scrollsave.html
Last active July 9, 2022 11:58 — forked from simonrw/scrollsave.html
Scroll position saver
<!-- Firefox jumps to the top after you reload a page and the developer tools are open. This is a script to prevent that. It is meant to be used just while development, then it should be removed. -->
<!doctype html>
<html>
<head>
<meta charset="utf8">
<style>
div#main {
border: 1px solid black;
display: inline-block;
width: 1024px;

Match a literal string

Using /coding/ you can look for the pattern coding inside a string.

Using OR operator

You can use operators inside your regex. The operator | matches the patterns either before or after it. If you wanted to match the string "yes" or "no" your regex would look like /yes|no/

@e93Ym0WnIO
e93Ym0WnIO / vanilla-js-cheatsheet.md
Created January 2, 2022 09:55 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@e93Ym0WnIO
e93Ym0WnIO / git-cheatsheet.txt
Last active March 19, 2022 04:27
Github working with branches cheatsheet
HOW TO CHANGE REMOTE REPOSITORY OF AN EXISTING PROJECT
$ git remote -v
will show you what are the remotes of the project and will look something like this:
origin git@github.com:nluciano233/rails-flight-booker.git (fetch)
origin git@github.com:nluciano233/rails-flight-booker.git (push)
$ git remote set-url origin git@github.com:nluciano233/rails-mailers.git
will set the remote to the url you want, then you can push changes into the new remote