blob: a93506050a071a7fb8a0333cb6e1d9f524aff0cc (
plain)
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
|
# Git tips and tricks
## Setup name and email
git config --global user.name "Name"
git config --global user.email "name@place.com"
## Delete remote branch
git push -d <remote> <branch>
## `git bisect`
git bisect start
git bisect new
git checkout <some commit a while ago>
git bisect old
git bisect run <command that returns 0 on old, 1 on new>
## Patches
git diff > change.patch
patch -p1 < change.patch # -p1 to remove the a/ and b/ from filepaths
## Exporting a commit
git archive <commit>
Outputs to stdout a tar archive of the index at the given commit. Make a
directory of just the code, not a repo:
git archive <commit> | tar --extract --directory <output dir>
## Remotes
Change remote url:
git remote set-url <remote> <new url>
## git log
Find commits that added or removed a particular string (specifically, where the
number of occurences changed):
git log -S <pattern>
Find commits that contain the given pattern in the diff:
git log -G <pattern>
|