Skip to content

Instantly share code, notes, and snippets.

@washanhanzi
Last active April 20, 2020 17:30
Show Gist options
  • Save washanhanzi/3abf842a8fe80f2bde1c11a04b1e7722 to your computer and use it in GitHub Desktop.
Save washanhanzi/3abf842a8fe80f2bde1c11a04b1e7722 to your computer and use it in GitHub Desktop.

Revisions

  1. washanhanzi revised this gist Apr 20, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -77,6 +77,10 @@ git reset origin/dev
    git add --all
    git commit -m 'my commit message'
    ```
    # clear cache
    ```
    git rm -rf --cached .
    ```

    # show lines of all file
    ```
  2. washanhanzi revised this gist Apr 13, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions git_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -78,6 +78,11 @@ git add --all
    git commit -m 'my commit message'
    ```

    # show lines of all file
    ```
    git ls-files | xargs wc -l
    ```

    # set proxy
    ```
    git config --global http.proxy http://localhost:7890
  3. washanhanzi revised this gist Apr 7, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ git config --global credential.github.com.useHttpPath true
    > https://github.com/microsoft/Git-Credential-Manager-for-Windows/issues/749
    - locally store credentials
    @.gitconfig
    @.git/config
    ```
    [credential]
    helper = store
    @@ -48,7 +48,7 @@ git config --global user.email "[email protected]"
    ```

    - locally user info
    @.gitconfig
    @.git/config
    ```
    [user]
    name = frank
  4. washanhanzi revised this gist Feb 26, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions git_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -76,4 +76,9 @@ git push -f origin master
    git reset origin/dev
    git add --all
    git commit -m 'my commit message'
    ```

    # set proxy
    ```
    git config --global http.proxy http://localhost:7890
    ```
  5. washanhanzi created this gist Jan 7, 2020.
    79 changes: 79 additions & 0 deletions git_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    # Credentials

    - clear credential cache
    ```shell
    git config --global --unset credential.helper
    git config --system --unset credential.helper
    ```

    - set credential manager (windows)
    ```shell
    git config --global credential.helper manager
    ```

    - multiple account (windows)
    ```
    git config --global credential.github.com.useHttpPath true
    ```
    > https://github.com/microsoft/Git-Credential-Manager-for-Windows/issues/749
    - locally store credentials
    @.gitconfig
    ```
    [credential]
    helper = store
    ```

    - locally store credentials
    ```shell
    git config --global credential.helper store
    ```

    - cache credentials expire 15min
    ```shell
    git config --global credential.helper cache
    ```

    - cache credentials for custom expire time
    ```shell
    git config --global credential.helper 'cache --timeout=3600'
    ```

    # User Info

    - global set user info
    ```shell
    git config --global user.name "frank"
    git config --global user.email "[email protected]"
    ```

    - locally user info
    @.gitconfig
    ```
    [user]
    name = frank
    email = [email protected]
    ```

    # Ignore File

    @.gitignore

    # Clear Commits History

    ```
    git checkout --orphan temp_branch
    git add -A
    git commit -am "init"
    git branch -D master
    git branch -m master
    git push -f origin master
    ```

    # reset branch and squash commits

    ```
    git reset origin/dev
    git add --all
    git commit -m 'my commit message'
    ```