categories | tags | Aimee's Blog
Aimee's Study Notes

It is updated automatically after each commit to the org-notes repo. It was last updated on Jul 28, 2021 19:05 UTC.


This page was created/modified in commit 4abc241 "update EDITOR" on 2021-07-28.
Markdown source of this page

Cheatsheet

categories: hacking

tags: git emacs orgmode


Description/Summary

My cheatsheet about Git and Emacs.

Content

Emacs & org-mode

References

Examples

Indent code: Ctrl + X, Tab, left/right

echo -e "test"

src_sh[:exports code]{echo -e "test"}

fn main()

~fn main()~

verbatim text

=verbatim text=

Git commands

Change the default editor for terminal

Use Emacs instead of Vim as the default editor for opening a file in terminal:

in the file “~/.bash_profile”:

$ export EDITOR=emacs

Git tutorial

https://github.com/git/git/blob/master/Documentation/gittutorial.txt

$ git show HEAD^  # to see the parent of HEAD
$ git show HEAD^^ # to see the grandparent of HEAD
$ git show HEAD~4 # to see the great-great grandparent of HEAD

Git commit log

It outputs a list of the email domains who have committed to the repository in the last 100,000 commits.

$ git log -n100000 --format="%ae" | cut -d@ -f2 | sort | uniq -c | sort -nr | less

Remote .git

$ ls .git
$ rm .git
rm: .git: is a directory
$ rm -rf .git

Download a file from command line

$ curl -LO https://upload.wikimedia.org/wikipedia/commons/c/c4/Creative-Tail-Halloween-ghost.svg
$ curl -L https://upload.wikimedia.org/wikipedia/commons/7/74/Twemoji2_1f47b.svg > ghost.svg

Cherry pick

$ git remote add some_github_id https://github.com/some_github_id/rust-in-blockchain.git
$ git fetch some_github_id
$ git log some_github_id/master
$ git cherry-pick some_commit_hash
$ git diff HEAD^..HEAD
$ git push origin master

Reset a commit

$ git reset HEAD^
$ git rm */~
$ git rm */*~
$ git commit --amend
$ git log
commit ad8b178eb99e414f7eb298798acbe1317099cc1b (HEAD -> master)

More: Git Tools - Rewriting History

Hide changes and do not commit

$ git stash

Cancel hiding

$ git stash pop

Merge a PR and edit it

$ git remote add <someones_github_id> https://github.com/<someones_github_id>/rust-in-blockchain.git
$ git fetch <someones_github_id>
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 4), reused 6 (delta 2), pack-reused 0
Unpacking objects: 100% (8/8), done.
From https://github.com/<someones_github_id>/rust-in-blockchain
 * [new branch]      master     -> <someones_github_id>/master # this one is on master branch

$ git merge <someones_github_id>/master

Add submodule to rib

$ ln -> means link

Creat an aliase for syncing file

$ ln -s ../awesome-blockchain-rust/README.md awesome-blockchain-rust.md

Recover to previous clean code

$ git checkout -f

About PATH

$ pwd
$ echo $PWD
$ export PATH=$PATH:$PWD

SSH

$ eval `ssh-agent`
$ ssh-add
$ ssh -T git@github.com

Generated a new key

$ ssh-keygen -C your@email.com

Copy it to GitHub settings:

$ cat ~/.ssh/id_rsa.pub

Move a file to current

$ git mv www/contracts .

This site is generated with ox-hugo for Emacs/Org-mode + hugo-bare-min-theme [Aimee's Study Notes]