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 Oct 09, 2021 05:00 UTC.

This page was created/modified in commit ce76b3e "." on 2021-10-08.
Markdown source of this page


categories: hacking

tags: git emacs orgmode


My cheatsheet about Git and Emacs.


Emacs & org-mode



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

$ 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
$ curl -L > ghost.svg

Cherry pick

$ git remote add some_github_id
$ 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


$ git log
$ git rebase c7cf210cee5c664f8e8169226de4019daf3643b9^ -i
$ git fetch origin
$ git rebase origin/master
# Remove some commits from the history

Clean up changes

$ git status
On branch docs-keypair
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
      modified:   sdk/src/

Untracked files:
  (use "git add <file>..." to include in what will be committed)

no changes added to commit (use "git add" and/or "git commit -a")

$ git clean -df

Ignore local changes

$ git diff
diff --git a/sdk/src/ b/sdk/src/
index 668f5d07b..1da23d35d 100644
--- a/sdk/src/
+++ b/sdk/src/
@@ -296,7 +296,7 @@ mod tests {
     use super::*;
     use crate::signature::{Keypair, Signer};
     use std::path::PathBuf;
+    use tempfile::{tempdir, tempfile, NamedTempFile};
     fn make_tmp_path(name: &str) -> PathBuf {
         let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());
         let keypair = Keypair::new();
$ git checkout -f

Cancel hiding

$ git stash pop

Merge a PR and edit it

$ git remote add <someones_github_id><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.
 * [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/

Recover to previous clean code

$ git checkout -f

About PATH

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


$ eval `ssh-agent`
$ ssh-add
$ ssh -T

Generated a new key

$ ssh-keygen -C

Copy it to GitHub settings:

$ cat ~/.ssh/

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]