aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-09-14 14:40:19 +0800
committerGuangxiong Lin <[email protected]>2022-09-14 14:40:19 +0800
commit7b90b441242910aca721e3cbf19370cdb5e25954 (patch)
treead279b87b7404922e6f4a5c3f6d2964477683e80
parent2cb5e8288f9135aef85d657710e6be1823376600 (diff)
downloadcheatsheet-7b90b441242910aca721e3cbf19370cdb5e25954.tar.gz
cheatsheet-7b90b441242910aca721e3cbf19370cdb5e25954.tar.bz2
cheatsheet-7b90b441242910aca721e3cbf19370cdb5e25954.zip
More git cheatsheet
-rw-r--r--git6
-rw-r--r--git-workflows10
2 files changed, 16 insertions, 0 deletions
diff --git a/git b/git
index fdc9baa..8b9cf0a 100644
--- a/git
+++ b/git
@@ -6,6 +6,12 @@ tags: [ vcs ]
# Show contents of a file
git show revision:path/to/file
+# Recover a file
+git restore --source=<commit or branch> path/to/file
+
+# Find which branches contain a specific commit
+git branch --contains <commit hash>
+
# Run commands in all existing commit
git filter-branch --tree-filter 'shell command' HEAD
diff --git a/git-workflows b/git-workflows
new file mode 100644
index 0000000..577833b
--- /dev/null
+++ b/git-workflows
@@ -0,0 +1,10 @@
+# Create a fixup commit
+git commit --fixup <commit hash>
+
+# Conduct the fixup
+# After running this command, the fixup commit will automatically show
+# after the commit to fix.
+git rebase -i --autosquash <commit hash>
+
+# related config
+git config --global rebase.autosquash true