Table of Contents
04 Debugging
Error Messages
File Path Too Long
Checking out d6d02b91 as v3.5.1... error: unable to create file some/long/path/here: Filename too long
Git has a limit of 4096 characters for a filename, except on Windows when Git is using msys. It uses an older version of the Windows API and there's a limit of 260 characters for a filename (details: https://github.com/msysgit/git/pull/110). This can be worked around by setting
git config --global core.longpaths true
Git is build as a combination of scripts and compiled code. With the above change some of the scripts might fail. That's the reason for core.longpaths not to be enabled by default.
Server certificate verification failure
For some setups, the SSL certificate verification will fail. Error messages might be:
error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing (repo)
or
Cloning into 'c:\repo-path'... ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository
or
fatal: unable to access 'https://xxx/yyy.git/': error setting certificate verify locations: CAfile: C:\xxx\yyy.tmp\CI_SERVER_TLS_CA_FILE CApath: none
If it is acceptable to turn off the SSL validation instead of actually solving the issue this will turn off validation for the current repo
git config --local http.sslVerify false
If you would rather have this as a default behaviour for git then the following will do it for all repos
git config --global http.sslVerify false
and for those that would rather add to the .git/config file directly the entry looks like
[http]
sslVerify = false
Dubious ownership in repository
If you encounter an error like
Error 510601:fatal: detected dubious ownership in repository at '<directory>' '<yourRepo>' is owned by: 'S-1-5-32-544' but the current user is: 'S-1-5-21-2616068622-1139830877-1444127923-1001' To add an exception for this directory, call: git config --global --add safe.directory C:/GitLab-Runner/builds/Kip4DNkXi/0/<yourRepo>
You might be using multiple Windows user accounts - one has cloned the repo initially, the other tries to use it now. Using the –system flag with the '*' wildcard, will disable ownership verification for all the users and all the repositories :
git config --system --add safe.directory '*' # For all users and all repositories
The wildcard '*' is only available for git version > 2.36
Transport 'file' not allowed
By default, only known-safe protocols (http, https, git, ssh) are allowed in git. Known-dangerous protocols (ext) have a default policy of never, and all other protocols (including file) have a default policy of user.
Supported policies:
-
always - protocol is always able to be used.
-
never - protocol is never able to be used.
-
user - protocol is only able to be used when GIT_PROTOCOL_FROM_USER is either unset or has a value of 1. This policy should be used when you want a protocol to be directly usable by the user but don’t want it used by commands which execute clone/fetch/push commands without user input, e.g. recursive submodule initialization.
How to allow the file protocol
git config --global protocol.file.allow always
See protocol.allow and protocol.<name>.allow in the git reference.
Commands For Fixing
Showing lost commits
git reflog
git log --graph --reflog
Discard changes
If your client is stuck and you cannot discard changes:
git clean -xfd git submodule foreach --recursive git clean -xfd git reset --hard git submodule foreach --recursive git reset --hard git submodule update --init --recursive
LFS / Smudge Filter
Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitLab.com.
The Git smudge filter is what converts the LFS pointer stored in Git with the actual large file from the LFS server. If your local repository does not have the LFS object, the smudge filter will have to download it. This means that network issues could affect the smudge filter.
An error message similar to the following will be displayed:
Error downloading object: some\path\to\a\file (1234abc): Errors logged to some\log\file.log Use `git lfs logs last` to view the log. error: external filter 'some filter process' failed fatal: some\path\to\a\file: smudge filter lfs failed
Usually, you can work around this by resetting your repository:
git reset --hard git pull
Manipulating Git Repos
BFG Repo-Cleaner
The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:
-
Removing Crazy Big Files
-
Removing Passwords, Credentials & other Private data
The git-filter-branch command is enormously powerful and can do things that the BFG can't - but the BFG is much better for the tasks above, because:
-
Faster : 10 - 720x faster
-
Simpler : The BFG isn't particularily clever, but is focused on making the above tasks easy
-
Beautiful : If you need to, you can use the beautiful Scala language to customise the BFG. Which has got to be better than Bash scripting at least some of the time.