Skip to content

Instantly share code, notes, and snippets.

@jeremypage
Last active June 5, 2025 02:26
Show Gist options
  • Save jeremypage/97d91c424dbd6e5f87ed to your computer and use it in GitHub Desktop.
Save jeremypage/97d91c424dbd6e5f87ed to your computer and use it in GitHub Desktop.

Revisions

  1. jeremypage revised this gist Feb 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ git config branch.master.mergeoptions "--no-ff"
    ## Move branch to master without checking out ##

    ```sh
    git branch -f branchToMove master
    git branch -f <BRANCH_TO_MOVE> master
    ```

    ## Speed up Git in Windows ##
  2. jeremypage revised this gist Dec 28, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    Git cheatsheet
    ==============

    ## Find all instances of text in all commits ##

    ```sh
  3. jeremypage revised this gist Nov 23, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    ## Find all instances of text in all commits ##

    ```sh
    git grep "text to look for" $(git rev-list --all)
    ```

    ## List commit messages since given commit ##

    ```sh
  4. jeremypage revised this gist Nov 2, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    ## List commit messages since given commit ##

    ```sh
    git log --pretty=format:%s HASH..HEAD
    ```

    ## Config repository master branch to only accept non-fast forward commits ##

    ```sh
  5. jeremypage revised this gist Oct 30, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,9 @@ Notes:
    git diff --name-status SHA1 SHA2
    ```

    ## Find largest file in repo ##
    ## Find largest files in repo ##

    Saves results to text file bigtosmall.txt

    (From http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history)

  6. jeremypage revised this gist Oct 30, 2015. 1 changed file with 22 additions and 5 deletions.
    27 changes: 22 additions & 5 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,17 @@
    ### Config repository master branch to only accept non-fast forward commits
    ## Config repository master branch to only accept non-fast forward commits ##

    ```sh
    git config branch.master.mergeoptions "--no-ff"
    ```
    **Hint:** Don't do this on your local working copy, or everytime you do a 'pull' from origin it will create yet another explicit commit (as opposed to a simple fast-forward).

    ### Move branch to master without checking out
    ## Move branch to master without checking out ##

    ```sh
    git branch -f branchToMove master
    ```

    ### Speed up Git in Windows
    ## Speed up Git in Windows ##

    (From http://stackoverflow.com/a/24045966)

    @@ -30,10 +30,27 @@ Notes:
    * `core.fscache` fixes UAC issues (don't need to run git as admin)

    * `gc.auto` minimizes the number of files in .git
    *

    ### Show all changed files between two Git commits ###
    ## Show all changed files between two Git commits ##

    ```sh
    git diff --name-status SHA1 SHA2
    ```

    ## Find largest file in repo ##

    (From http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history)

    ```sh
    git rev-list --objects --all | sort -k 2 > allfileshas.txt
    ```

    ```sh
    git gc && git verify-pack -v .git/objects/pack/pack-*.idx | egrep "^\w+ blob\W+[0-9]+ [0-9]+ [0-9]+$" | sort -k 3 -n -r > bigobjects.txt
    ```

    ```sh
    for SHA in `cut -f 1 -d\ < bigobjects.txt`; do
    echo $(grep $SHA bigobjects.txt) $(grep $SHA allfileshas.txt) | awk '{print $1,$3,$7}' >> bigtosmall.txt
    done;
    ```
  7. jeremypage revised this gist Oct 8, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    ```sh
    git config branch.master.mergeoptions "--no-ff"
    ```
    **Hint:** Don't do this on your local working copy, or everytime you do a 'pull' from origin it will create yet another explicit commit (as opposed to a simple fast-forward).

    ### Move branch to master without checking out

  8. jeremypage revised this gist Jul 13, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -34,5 +34,5 @@ Notes:
    ### Show all changed files between two Git commits ###

    ```sh
    git diff --name-only SHA1 SHA2
    git diff --name-status SHA1 SHA2
    ```
  9. jeremypage revised this gist Jul 13, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,6 @@ Notes:

    ### Show all changed files between two Git commits ###

    ```sh git diff --name-only SHA1 SHA2 ```
    ```sh
    git diff --name-only SHA1 SHA2
    ```
  10. jeremypage revised this gist Jul 13, 2015. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,9 @@ Notes:

    * `core.fscache` fixes UAC issues (don't need to run git as admin)

    * `gc.auto` minimizes the number of files in .git
    * `gc.auto` minimizes the number of files in .git
    *

    ### Show all changed files between two Git commits ###

    ```sh git diff --name-only SHA1 SHA2 ```
  11. jeremypage revised this gist Apr 15, 2015. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -16,9 +16,11 @@ git branch -f branchToMove master

    You can significantly speed up git on Windows by running three commands to set some config options:

    $ git config --global core.preloadindex true
    $ git config --global core.fscache true
    $ git config --global gc.auto 256
    ```sh
    git config --global core.preloadindex true
    git config --global core.fscache true
    git config --global gc.auto 256
    ```

    Notes:

  12. jeremypage revised this gist Apr 15, 2015. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,14 @@
    ### Config repository master branch to only accept non-fast forward commits

    ```sh
    git config branch.master.mergeoptions "--no-ff"
    ```

    ### Move branch to master without checking out

    git branch -f branchToMove master
    ```sh
    git branch -f branchToMove master
    ```

    ### Speed up Git in Windows

  13. jeremypage revised this gist Apr 13, 2015. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,21 @@
    ### Move branch to master without checking out

    git branch -f branchToMove master


    ### Speed up Git in Windows

    (From http://stackoverflow.com/a/24045966)

    You can significantly speed up git on Windows by running three commands to set some config options:

    $ git config --global core.preloadindex true
    $ git config --global core.fscache true
    $ git config --global gc.auto 256

    Notes:

    * `core.preloadindex` does filesystem operations in parallel to hide latency and will be enabled by default in future versions of git on all platforms (update: enabled in v2.1)

    * `core.fscache` fixes UAC issues (don't need to run git as admin)

    * `gc.auto` minimizes the number of files in .git
  14. jeremypage revised this gist Apr 13, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Move branch to master without checking out

    git branch -f master branchToMove
    git branch -f branchToMove master

  15. jeremypage created this gist Apr 13, 2015.
    4 changes: 4 additions & 0 deletions git-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    ### Move branch to master without checking out

    git branch -f master branchToMove