summaryrefslogtreecommitdiff
path: root/content/notes/git.md
blob: baed2b794fb1754ad45545c97d9480e02ea7607e (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
50
51
+++
title = 'git usage notes'
+++

## Documentation

* Official reference: https://git-scm.com/docs

## Commands I often forget

### Committing

Rebase the last 3 commits:
```
git rebase -i HEAD~3
```

Rebase all commits:
```
git rebase -i --root
```

### Working with remotes

Hard reset from remote:
```
git fetch
git reset --hard origin/master
```

### Searching commits

Search for commits containing text:
```
git log --grep="abc"
```

Case-insensitive version:
```
git log -i --grep="abc"
```

Search by author
```
git log --author="guy"
```

List contributors by commit count:
```
git shortlog --summary --numbered --all --no-merges
```