Repository navigation
Expand file tree
/
Copy pathreference.bash
More file actions
92 lines (72 loc) · 2.79 KB
/
Copy pathreference.bash
File metadata and controls
92 lines (72 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Git Recipes
# remove untracked
git clean
# ==========================================================
# GIT LFS
# ==========================================================
# un/install lfs hooks
git-lfs uninstall
git-lfs install
# Get required file from LFS
git-lfs pull --include '<big filename>'
# ==========================================================
# GIT STASH
# ==========================================================
git stash apply # pops but dont remove from stack
git stash -u # --include-untracked
git stash save "." # custom message
# rename stash
git stash drop stash@{0}
git stash store -m "..." <hash-printed-by-drop>
# ==========================================================
# GIT SUBMODULE
# ==========================================================
# Do on all submodues
git submodule foreach git ...
# commits which are in branch_a but not in branch_b
git submodule foreach git log branch_a --not branch_b --pretty=oneline --abbrev-commit
# ==========================================================
# GIT LOG
# ==========================================================
# commits which are in branch_a but not in branch_b
git log branch_a --not branch_b --pretty=oneline --abbrev-commit
# ==========================================================
# GIT REV-LIST
# ==========================================================
# count unmerged commits from remote to local
git rev-list branch_name..origin/branch_name --count
# count unpushed commits from local to remote
git rev-list origin/branch_name..branch_name --count
# ==========================================================
# GIT Bisect
# ==========================================================
# https://git-scm.com/docs/git-bisect
git bisect start
git bisect good [hash]
git bisect bad [hash]
# look for team commits and surrounding
git log --pretty=oneline | grep <string>
git log --pretty=oneline | grep -B 3 -A 2 <string> # 3 lines before, 2 after
git log --pretty=oneline | grep -C 3 <string> # 3 lines before and after
# ==========================================================
# GIT Cherry Pick
# ==========================================================
git cherry-pick <hash>
git cherry-pick --continue | --abort
# multiple commits
https://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits
# ==========================================================
# GIT PATCH
# ==========================================================
## How to create patches
1. Create patch branch
git checkout -b fix_something
2. Commit patches
3. Create patch pointing to original branch
git format-patch <my_branch> --stdout > fix_something.patch
4. Apply patches
git apply --stat fix_something.patch
## Create a commit to revert another
git revert <hash>
git revert -m 1 <PR merge hash>