Git snippets
September 26, 2019
git clone --depth=100 --no-single-branch
cd xxx
git remote set-branches origin '*'
git fetch -v
After doing a shallow clone, to be able to checkout other branches from remote ,
- Run (thanks @jthill): git remote set-branches origin '*'
- After that, do a git fetch -v
- Finally git checkout the-branch-i-ve-been-looking-for
From < https://stackoverflow.com/questions/23708231/git-shallow-clone-clone-depth-misses-remote-branches >
Git checkout as above doesn't work for me. However using Git Extensions it does. There must be another command line in there somewhere behind the scenes.
Warning: LF will be replaced by CRLF
- set the policy to false (matt's opinionated setting)
- reset the already downloaded and cached files, and index
# Show setting ("true" or "false" or "input")
git config core.autocrlf
# Make it so
git config --global core.autocrlf false
refresh the indexes and re-write git index with:
git rm --cached -r .
git reset --hard
Adapted from < https://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf/20653073#20653073 >
Clearing stored git username and passwords
elevate git config --system --unset credential.helper
git config --global --unset credential.helper
then for each repo:
git config --unset credential.helper
And then go to " Control Panel\User Accounts\Credential Manager" >> Windows Credentials >> Generic" and remove the GitHub entries.
After this using "git push" in console asked for credentials -- every time though. Still need to figure out how to safely save them for re-use.
Sources
Tell Git to use symlinks on Windows
git config --global core.symlinks true
From < https://getnikola.com/getting-started.html >
Troubleshooting
Our corporate firewall operates as MITM, yielding:
fatal: unable to access ' https://github.com/{project}/{repo}.git/ ': SSL certificate problem: self-signed certificate in certificate chain
The fix:
git config --global http.sslbackend schannel