Skip to content

Instantly share code, notes, and snippets.

@antonkomarev
Last active December 12, 2025 05:14
Show Gist options
  • Select an option

  • Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.

Select an option

Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.

Revisions

  1. antonkomarev revised this gist Dec 12, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ Opens an interactive rebase for all commits in the current branch **that are not
    Useful for squashing or editing only your new commits.

    ```shell
    git sq
    git rh
    ```

    ## git ru
  2. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    [alias]
    go = "!git switch ${1:-master} && git pull && git cleanup"
    sq = "!git rebase -i HEAD~$(git count)"
    rh = "!git rebase -i HEAD~$(git count)"
    ru = "!git rebase -i master"
    pf = "!git push --force-with-lease"

    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ Same command, but with another branch name to switch to:
    git go feature/custom-branch-name
    ```

    ## git sq
    ## git rh

    Opens an interactive rebase for all commits in the current branch **that are not yet in master**, automatically calculating the number of commits to rebase.
    Useful for squashing or editing only your new commits.
  3. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 18 additions and 9 deletions.
    1 change: 1 addition & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    [alias]
    go = "!git switch ${1:-master} && git pull && git cleanup"
    sq = "!git rebase -i HEAD~$(git count)"
    ru = "!git rebase -i master"
    pf = "!git push --force-with-lease"

    # secondary tool functions
    26 changes: 17 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,41 @@
    Add 2 aliases to `~/.gitconfig` file.

    ## git go

    1. switches to seleted branch (`master` by default)
    2. pulling changes from remote server
    3. deletes all local branches which were deleted remotely
    1. Switches to a selected branch (`master` by default)
    2. Pulls changes from the remote server
    3. Deletes all local branches which were deleted remotely

    ```shell
    git go
    ```

    Same command, but with another branch name to switch to.
    Same command, but with another branch name to switch to:

    ```shell script
    ```shell
    git go feature/custom-branch-name
    ```

    ## git sq

    Opens an interactive rebase for all commits in the current branch that are not in master branch.
    Opens an interactive rebase for all commits in the current branch **that are not yet in master**, automatically calculating the number of commits to rebase.
    Useful for squashing or editing only your new commits.

    ```shell
    git sq
    ```

    ## git ru

    Opens an interactive rebase of the current branch **on top of master**, using master as the fixed base.
    All commits in the branch will be reordered relative to master.

    ```shell
    git ru
    ```

    ## git pf

    Force push with `--force-with-lease` flag.

    ```shell
    git pf
    ```
    ```
  4. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 7 additions and 24 deletions.
    11 changes: 5 additions & 6 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@
    [alias]
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git switch ${1:-master} && git pull && git cleanup"
    sq = "!f() { \
    count=$(git rev-list --count HEAD ^$(git merge-base HEAD master)); \
    git rebase -i HEAD~$count; \
    }; f"
    puf = "!git push --force-with-lease"
    sq = "!git rebase -i HEAD~$(git count)"
    pf = "!git push --force-with-lease"

    # secondary tool functions
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    20 changes: 2 additions & 18 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,5 @@
    Add 2 aliases to `~/.gitconfig` file.

    ## git cleanup

    1. deletes all local branches which were deleted remotely.

    ```shell
    git cleanup
    ```

    ## git go

    1. switches to seleted branch (`master` by default)
    @@ -32,18 +24,10 @@ Opens an interactive rebase for all commits in the current branch that are not i
    git sq
    ```

    ## git puf
    ## git pf

    Force push with `--force-with-lease` flag.

    ```shell
    git puf
    ```

    ## git count

    Calculates the number of commits that are not in master branch.

    ```shell
    git count
    git pf
    ```
  5. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 10 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,5 @@
    count=$(git rev-list --count HEAD ^$(git merge-base HEAD master)); \
    git rebase -i HEAD~$count; \
    }; f"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    puf = "!git push --force-with-lease"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    8 changes: 8 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,14 @@ Opens an interactive rebase for all commits in the current branch that are not i
    git sq
    ```

    ## git puf

    Force push with `--force-with-lease` flag.

    ```shell
    git puf
    ```

    ## git count

    Calculates the number of commits that are not in master branch.
  6. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 9 additions and 9 deletions.
    4 changes: 2 additions & 2 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    [alias]
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git switch ${1:-master} && git pull && git cleanup"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    sq = "!f() { \
    count=$(git rev-list --count HEAD ^$(git merge-base HEAD @{upstream})); \
    count=$(git rev-list --count HEAD ^$(git merge-base HEAD master)); \
    git rebase -i HEAD~$count; \
    }; f"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    14 changes: 7 additions & 7 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -24,18 +24,18 @@ Same command, but with another branch name to switch to.
    git go feature/custom-branch-name
    ```

    ## git count
    ## git sq

    Calculates the number of commits that are not in master branch.
    Opens an interactive rebase for all commits in the current branch that are not in master branch.

    ```shell
    git count
    git sq
    ```

    ## git sq
    ## git count

    Opens an interactive rebase for all commits in the current branch that are not in master branch.
    Calculates the number of commits that are not in master branch.

    ```shell
    git sq
    ```
    git count
    ```
  7. antonkomarev revised this gist Sep 4, 2025. 2 changed files with 25 additions and 4 deletions.
    5 changes: 5 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    [alias]
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git switch ${1:-master} && git pull && git cleanup"
    count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
    sq = "!f() { \
    count=$(git rev-list --count HEAD ^$(git merge-base HEAD @{upstream})); \
    git rebase -i HEAD~$count; \
    }; f"
    24 changes: 20 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,41 @@
    Add 2 aliases to `~/.gitconfig` file.

    ## Git cleanup
    ## git cleanup

    1. deletes all local branches which were deleted remotely.

    ```shell script
    ```shell
    git cleanup
    ```

    ## Git go
    ## git go

    1. switches to seleted branch (`master` by default)
    2. pulling changes from remote server
    3. deletes all local branches which were deleted remotely

    ```shell script
    ```shell
    git go
    ```

    Same command, but with another branch name to switch to.

    ```shell script
    git go feature/custom-branch-name
    ```

    ## git count

    Calculates the number of commits that are not in master branch.

    ```shell
    git count
    ```

    ## git sq

    Opens an interactive rebase for all commits in the current branch that are not in master branch.

    ```shell
    git sq
    ```
  8. antonkomarev revised this gist Sep 13, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    [alias]
    cleanup = "!git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -D"
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git switch ${1:-master} && git pull && git cleanup"
  9. antonkomarev revised this gist Sep 13, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    [alias]
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git checkout ${1:-master} && git pull && git cleanup"
    cleanup = "!git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -D"
    go = "!git switch ${1:-master} && git pull && git cleanup"
  10. antonkomarev revised this gist Sep 10, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -21,5 +21,5 @@ git go
    Same command, but with another branch name to switch to.

    ```shell script
    git go any-custom-branch-name
    git go feature/custom-branch-name
    ```
  11. antonkomarev revised this gist Sep 10, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,8 @@ git cleanup
    git go
    ```

    Same command, but with another branch name to switch to.

    ```shell script
    git go any-custom-branch-name
    ```
  12. antonkomarev revised this gist Sep 10, 2020. No changes.
  13. antonkomarev revised this gist Sep 10, 2020. No changes.
  14. antonkomarev created this gist Sep 10, 2020.
    3 changes: 3 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    [alias]
    cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
    go = "!git checkout ${1:-master} && git pull && git cleanup"
    23 changes: 23 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    Add 2 aliases to `~/.gitconfig` file.

    ## Git cleanup

    1. deletes all local branches which were deleted remotely.

    ```shell script
    git cleanup
    ```

    ## Git go

    1. switches to seleted branch (`master` by default)
    2. pulling changes from remote server
    3. deletes all local branches which were deleted remotely

    ```shell script
    git go
    ```

    ```shell script
    git go any-custom-branch-name
    ```