├── OptimazingSSH.sh ├── README.md ├── gitspeedup.sh └── gitspeedupL.sh /OptimazingSSH.sh: -------------------------------------------------------------------------------- 1 | printf "Start to SSH Optimazing" 2 | cat ~/.ssh/config 3 | 4 | echo "Enables the sharing of multiple SSH sessions over a single network connection, and auto-creating a master connection if it does not already exist." 5 | 6 | printf 'ControlMaster auto \n' >~/.ssh/config 7 | 8 | echo "specifies the path to the control socket used for connection sharing. %r will be substituted by the remote login username, %h by the target host name and %p by the port." 9 | 10 | echo 'ControlPath /tmp/%r@%h:%p' >>~/.ssh/config 11 | echo "keeps the master connection open in the background indefinitely" 12 | 13 | echo 'ControlPersist yes ' >>~/.ssh/config 14 | printf "Finished Optimazing SSH " 15 | 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # git-speedup 2 | Speed up git bash on windows, also works on Mac machines. Including improvement of speed of executing git status, git add, git pull, git push, ls, cd etc. 3 | ## Losing track of files 4 | ``` 5 | git branch --set-upstream YOUR_BRANCH_NAME upstream/YOUR_BRANCH_NAME 6 | ``` 7 | # Three Vesions 8 | ### gitspeedup.sh ---- Small projects 9 | Which disEnable the ignoreStat, can use the ```git add ``` when we have some changed 10 | ### gitspeedupL.sh ---- Large projects 11 | Which enable the ignoreStat, please use the 12 | ```git update-index --really-refresh 13 | ``` when we have changed files 14 | ### OptimazingSSH.sh ---- Any Projects which are using SSH 15 | Which optimazing the SSH setting 16 | 17 | # How is work 18 | 19 | #### 1. Repack the obects, the default was not to change the window or depth at all. As suggested by Jon Smirl, Linus Torvalds and others 20 | ```bash 21 | git repack -a -d --depth=250 --window=250 22 | ``` 23 | For more detail, please visit link: 24 | http://git.661346.n2.nabble.com/git-repack-vs-git-gc-aggressive-td7564559.html 25 | 26 | #### 2. Enable git preload file index 27 | ```bash 28 | git config --global core.preloadindex true 29 | ``` 30 | 31 | #### 3. Avoid inspecting large working trees' modification times 32 | ```bash 33 | git config core.ignoreStat true 34 | ``` 35 | When working with **large working** trees, Git's (frequent) checking whether files were modified since Git's internal index was last updated can lead to substantial lags. In such a case, it can make sense to switch off this check, but it comes at a price: it requires discipline on the developer's side to keep track which files were changed and git add them explicitly for the next commit (the output of git status will no longer identify modified files). You can disable the check per-repository thusly 36 | 37 | When ```bash git mv ```and ```bash git rm``` are used, those changes do get noticed, even on assume-unchanged files. When new files are added, eg by git annex add, they are also noticed, then, 38 | please use following code instead ```bash git add ``` 39 | ```bash 40 | git update-index --really-refresh 41 | ``` 42 | For more detail, please visit link: https://git-annex.branchable.com/tips/assume-unstaged/ 43 | 44 | #### 4. Enble file system cache for local 45 | ```bash 46 | git config core.fscache true 47 | ``` 48 | 49 | #### 5. Enble file system cache for global 50 | ```bash 51 | git config --global core.fscache true 52 | ``` 53 | 54 | #### 6. Cleanup unnecessary files and optimize the local repository 55 | ```bash 56 | git config --global gc.auto 256 57 | ``` 58 | 59 | #### 7. Enables the sharing of multiple SSH sessions over a single network connection, and auto-creating a master connection if it does not already exist 60 | ```bash 61 | ControlMaster auto 62 | ``` 63 | #### 8. Specifies the path to the control socket used for connection sharing. %r will be substituted by the remote login username, %h by the target host name and %p by the port. 64 | ```bash 65 | ControlPath /tmp/%r@%h:%p 66 | ``` 67 | #### 9. Keeps the master connection open in the background indefinitely 68 | ```bash 69 | ControlPersist yes 70 | ``` 71 | # How to use this 72 | 73 | ## Just run this sh file by double click 74 | 75 | ## Using code to run this in git 76 | ```bash 77 | sh Script.sh 78 | ``` 79 | ### Plan A 80 | ```bash 81 | # Set the execution for all the users for the given script 82 | chmod +x Script.sh 83 | 84 | # Execute the script 85 | ./Script.sh 86 | ``` 87 | 88 | ### Plan B 89 | ```bash 90 | # Set the execution for all the users for the given script 91 | chmod 777 /PATHTOFILE/Script.sh 92 | 93 | # Execute the script 94 | /PATHTOFILE/Script.sh 95 | ``` 96 | 97 | ## Another way to make git faster (From online) 98 | I found the following change on a StackOverflow post that seems to work way faster: 99 | 100 | Go to your git install directory (Mine is c:\Program Files (x86)\Git 101 | In the etc folder, open the file 'profile' in a text editor 102 | This file is executed when the bash shell is initialized, you can do a lot of customization in here 103 | Near the bottom, you will find some commands related to setting a variable called PS1 (PS1 = ...) 104 | Either replace it or just append the following lines after it 105 | 106 | ```bash 107 | fast_git_ps1 () 108 | { 109 | printf -- "$(git branch 2>/dev/null | grep -e '\* ' | sed 's/^..\(.*\)/ {\1} /')" 110 | } 111 | 112 | PS1='\[\033]0;$MSYSTEM:\w\007 113 | \033[32m\]\u@\h \[\033[33m\w$(fast_git_ps1)\033[0m\] 114 | $ 115 | ``` 116 | 117 | # Deleted Code 118 | 119 | ```bash 120 | GIT_TRACE=1 git stash, this code was removed. 121 | ``` 122 | ##### Activate Git's own tracing, because the Git bash executes subcommands, this will be executes internally 123 | -------------------------------------------------------------------------------- /gitspeedup.sh: -------------------------------------------------------------------------------- 1 | echo "Start To Speed Up Git On your Windows Machine!" 2 | 3 | echo "Repack the objects which are useless by Counting and Compressing" 4 | git repack -a -d --depth=250 --window=250 5 | # The default was not to change the window or depth at all. As suggested by Jon Smirl, Linus Torvalds and others 6 | 7 | #echo "Activate Git's own tracing" 8 | #GIT_TRACE=1 git stash #Activate Git's own tracing 9 | 10 | echo "Enable git preload file index" 11 | git config --global core.preloadindex true #Enable git preload file index 12 | 13 | echo "Enable Global git cache filesystem " 14 | git config --global core.fscache true #Enable the filesystem cache 15 | 16 | echo "Enable Local git cache filesystem " 17 | git config core.fscache true 18 | 19 | echo "Cleanup unnecessary files and optimize the local repository" 20 | git config --global gc.auto 256 #Set auto clean to be 256, to save memory 21 | 22 | echo "Enable inspecting small working trees' modification times" 23 | git config --global core.ignoreStat true # 24 | 25 | # These can be worked around by running git update-index --really-refresh after performing such operations. I hope that git add will be changed to stage changes to assume-unchanged files, which would remove this only complication 26 | 27 | echo "Finishing Optimazing Git" 28 | 29 | 30 | -------------------------------------------------------------------------------- /gitspeedupL.sh: -------------------------------------------------------------------------------- 1 | echo "Start To Speed Up Git On your Windows Machine!" 2 | 3 | 4 | echo "Repack the objects which are useless by Counting and Compressing" 5 | git repack -a -d --depth=250 --window=250 6 | # The default was not to change the window or depth at all. As suggested by Jon Smirl, Linus Torvalds and others 7 | 8 | echo "Enable git preload file index" 9 | git config --global core.preloadindex true #Enable git preload file index 10 | 11 | echo "Enable Global git cache filesystem " 12 | git config --global core.fscache true #Enable the filesystem cache 13 | 14 | echo "Enable Local git cache filesystem " 15 | git config core.fscache true 16 | 17 | echo "Cleanup unnecessary files and optimize the local repository" 18 | git config --global gc.auto 256 #Set auto clean to be 256, to save memory 19 | 20 | echo "Avoid inspecting large working trees' modification times" 21 | git config --global core.ignoreStat true 22 | 23 | # These can be worked around by running git update-index --really-refresh after performing such operations. I hope that git add will be changed to stage changes to assume-unchanged files, which would remove this only complication 24 | 25 | # https://git-annex.branchable.com/tips/assume-unstaged/ 26 | 27 | echo "Finishing Optimazing Git" 28 | 29 | echo "Please use git update-index --really-refresh when you make any changes" --------------------------------------------------------------------------------