aboutsummaryrefslogtreecommitdiff
path: root/git.cheat
blob: e690ad0d8c11310e6f5ef0f32d343e7adc7cde73 (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
% git

# Fixup commit
git commit --fixup <commit_id>

# Rebase
git rebase -i <commit_id>

# Checkout
git checkout <branch>

# Delete a branch
git branch -d <branch>

# Get the remote url of origin
git remote get-url origin

# Diff a specific file between commits
git diff \
    --ignore-space-change \
    <start_commit_id>..<end_commit_id> \
    -- <files_changed_between_commits>

# Diff files changed compared to master branch
git diff \
    --ignore-space-change \
    -- <files_changed_compared_to_master_branch>

# Show the files changed compare to master branch
git diff --stat --merge-base <master_branch>

$ commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
$ branch: git branch | awk '{print $NF}'

$ start_commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
$ end_commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
$ files_changed_between_commits: git diff --name-only <start_commit_id>..<end_commit_id>

$ master_branch: git symbolic-ref --short refs/remotes/origin/HEAD
$ files_changed_compared_to_master_branch: git diff --name-only --merge-base <master_branch>