d48cbb82b1a44d646c6b12b6bfb13c5fd366e1ae
Author Unnit Metaliya <unnitjmetaliya@gmail.com> Committer GitHub <noreply@github.com> Date 2023-02-06 11:07 UTC
Message feat(git)!: add `force-if-includes` flag (#11481)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Closes #11388
BREAKING CHANGE: `gpf` and `gpsupf` now have the `--force-if-includes` flag if git version is greater than 2.30. It will make force pushes more safer. See https://stackoverflow.com/questions/65837109/when-should-i-use-git-push-force-if-includes
Diff 1 diff --git a/plugins/git/README.md b/plugins/git/README.md
2 index d5eaaa53f15e2b835b6f0057a08104f30f93a8ca..cd018d435e32c602f585b35de3f9a115deabeb8e 100644
3 --- a/plugins/git/README.md
4 +++ b/plugins/git/README.md
5 @@ -89,7 +89,8 @@ plugins=(... git)
6 | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
7 | ggu | git pull --rebase origin $(current_branch) |
8 | gpsup | git push --set-upstream origin $(git_current_branch) |
9 -| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease |
10 +| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) |
11 +| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) |
12 | ghh | git help |
13 | gignore | git update-index --assume-unchanged |
14 | gignored | git ls-files -v \| grep "^[[:lower:]]" |
15 @@ -120,6 +121,8 @@ plugins=(... git)
16 | gp | git push |
17 | gpd | git push --dry-run |
18 | gpf | git push --force-with-lease |
19 +| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) |
20 +| gpf | git push --force-with-lease (git version < 2.30) |
21 | gpf! | git push --force |
22 | gpoat | git push origin --all && git push origin --tags |
23 | gpr | git pull --rebase |
24 diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
25 index fc2c08ccda7b5da43de86777787eb86980d8f0bc..7541ccff2511a936086e03ad25c5470a2cc285f6 100644
26 --- a/plugins/git/git.plugin.zsh
27 +++ b/plugins/git/git.plugin.zsh
28 @@ -199,7 +199,9 @@ alias ggpush='git push origin "$(git_current_branch)"'
29
30 alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
31 alias gpsup='git push --set-upstream origin $(git_current_branch)'
32 -alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
33 +is-at-least 2.30 "$git_version" \
34 + && alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
35 + || alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
36
37 alias ghh='git help'
38
39 @@ -235,7 +237,9 @@ alias gma='git merge --abort'
40
41 alias gp='git push'
42 alias gpd='git push --dry-run'
43 -alias gpf='git push --force-with-lease'
44 +is-at-least 2.30 "$git_version" \
45 + && alias gpf='git push --force-with-lease --force-if-includes' \
46 + || alias gpf='git push --force-with-lease'
47 alias gpf!='git push --force'
48 alias gpoat='git push origin --all && git push origin --tags'
49 alias gpr='git pull --rebase'