Skip to content

Instantly share code, notes, and snippets.

@peterkir
Last active October 14, 2023 10:53
Show Gist options
  • Save peterkir/ee9079e3e8bca8c4b09073902f9cc1e8 to your computer and use it in GitHub Desktop.
Save peterkir/ee9079e3e8bca8c4b09073902f9cc1e8 to your computer and use it in GitHub Desktop.
GIT KnowHow

GIT Know-How

FAQ - Troubleshooting

Debug

Assure git server connection is working with a specific keyfile ssh -o "IdentitiesOnly=yes" -i ~/.ssh/id_ed25519_pekirsc_AT_git_i_mercedes-benz_com <git-ssh-server, e.g. [email protected]

Activate Trace when cloning GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone --verbose <git-ssh-clone-uri, e.g. [email protected]/klibio/test>

Most detailed debugging

set -x; 
GIT_TRACE=2 
GIT_CURL_VERBOSE=2 
GIT_TRACE_PERFORMANCE=2 
GIT_TRACE_PACK_ACCESS=2 
GIT_TRACE_PACKET=2 
GIT_TRACE_PACKFILE=2 
GIT_TRACE_SETUP=2 
GIT_TRACE_SHALLOW=2 
git pull origin master -v -v; 
set +x

Executable Flag

During file addition git add --chmod=+x -- <exe-file>

on existing files git update-index --chmod=+x *.sh

Fix line ending issues

https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows/13154031#13154031

Authentication failed on GSEP Daimler - after password change

execute this inside the git bash in the repo location and try again. Brings the cred pop-up back.

git config --global --unset credential.helper

... schannel: Failed to get certificate location for ...

copy of 'SSL certificate problem: unable to get local issuer certificate' when trying to clone repos

git config -l --show-origin

Your Git for Windows has a system Git configuration with these values:

[http]
    sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    sslbackend=schannel

GitHub Desktop won't see these values, as it has it's own system configuration file with http.sslbackend=schannel set. This means it'll use the Windows Certificate Store to validate server certificates.

In your global ~/.gitconfig you've set http.sslbackend back to the classic openssl. GitHub Desktop will use these values, but without also setting http.sslcainfo it's going to fail on all clones - because no backing store is found for Desktop.

So you have two options:

  • in corporate network e.g. Daimler just comment the section of http and the sub-keys inside the global .gitconfig file
  • if you don't need to set http.sslbackend=openssl globally, removing that value should make Desktop work
  • if you need http.sslbackend=openssl set globally, you should also set http.sslcainfo so that GitHub Desktop has a backing store of certificates to validate

.gitignore

entry Ignores every…
target/ …folder (due to the trailing /) recursively
target …file or folder named target recursively
/target …file or folder named target in the top-most directory (due to the leading /)
/target/ …folder named target in the top-most directory (leading and trailing /)
*.class …every file or folder ending with .class recursively

Advanced Use Cases

entry Ignores every…
#comment …nothing, this is a comment (first character is a #)
#comment …every file or folder with name #comment (\ for escaping)
target/logs/ …every folder named logs which is a subdirectory of a folder named target
target/*/logs/ …every folder named logs two levels under a folder named target (* doesn’t include /)
target/**/logs/ …every folder named logs somewhere under a folder named target (** includes /)
*.py[co] …file or folder ending in .pyc or .pyo. However, it doesn’t match .py!
!README.md Doesn’t ignore any README.md file even if it matches an exclude pattern, e.g. *.md.
NOTE This does not work if the file is located within a ignored folder.

empty folder - which exists in repo but stays emtpy

create and commit the folder and a containing file .gitignore with the following content

# ignore everything in this directory
*
# except this file
!.gitignore

Usecases

Finding a branch point with Git?

https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git

Visual Merging Tool

https://stackoverflow.com/questions/137102/whats-the-best-visual-merge-tool-for-git https://www.slant.co/topics/48/~best-visual-merge-tools-for-git

Commands

git merge --no-ff https://stackoverflow.com/a/6701322/2918516

Background Information

http://think-like-a-git.net/sections/graph-theory.html

GitFlow

http://nvie.com/posts/a-successful-git-branching-model/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment