Skip to content

Commit 3d3ef4a

Browse files
committed
improve git cheat sheet
1 parent 1981744 commit 3d3ef4a

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

docs/posts/2019/2019-06-19-git-cheat-sheet.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ categories:
66
comments: true
77
date:
88
created: 2019-06-19
9-
updated: 2025-05-18
10-
description: Some personal often forgotten git commands.
9+
updated: 2025-07-09
1110
---
1211

1312
# Git Cheat Sheet
1413

15-
This is not a complete Git cheat sheet for everyone, this is just a personal cheat sheet for some often forgotten git commands.
14+
This is not a complete Git cheat sheet for everyone, this is just a personal cheat sheet.
1615

1716
<!-- more -->
1817

@@ -218,6 +217,34 @@ git cherry-pick another_local_branch
218217
get rebase another_local_branch
219218
```
220219

220+
### get branches contains a commit
221+
222+
```bash
223+
# local branches
224+
git branch --contains <commit>
225+
226+
# remote branches
227+
git branch -r --contains <commit>
228+
```
229+
230+
### get branches pointing to a commit
231+
232+
```bash
233+
# local branches
234+
git branch --points-at <commit>
235+
236+
# remote branches
237+
git branch -r --points-at <commit>
238+
239+
# get remote branches pointing to HEAD
240+
# useful in Jenkins run if you want to know which remote branches
241+
# are pointing to the current commit. (i.e. Jenkins pipeline branch)
242+
# If multiple remote branches are pointing to the same commit,
243+
# this command will return all of them,
244+
# so won't work if you want to get only one remote branch.
245+
git branch -r --points-at HEAD
246+
```
247+
221248
## Show diff
222249

223250
### show content in staging area

0 commit comments

Comments
 (0)