Tag Archives: git

[Solved] Remote URL test failed: Could not read from remote repository.


I set a password when I generated the key, which caused this problem


1. Regenerate the key through the command

ssh-keygen -t rsa -C "[email protected]"

Enter three times in a row, do not set a password (I just set a password here and caused the problem)

2. Go to C:\Users\username\.ssh and copy the content of id_rsa.pub, and then add it to gitlab (title will be automatically generated)

[Solved] fatal: not in a git directory Error: Command failed with exit 128: git

fatal: not in a git directory Error: Command failed with exit 128: git

brew install cmake  execute error:

Already downloaded: /Users/kingcall/Library/Caches/Homebrew/downloads/b7ef8d6eb909e967d072212c62e71bfb8e94e6227ae2d3567bbabcc561fd9fff--cmake-3.21.4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:c86a0bb0e37c293e2d4475519d28f2784c430e871f74969a1a2afeb64b540a7d
Already downloaded: /Users/kingcall/Library/Caches/Homebrew/downloads/1e8ca69a4444469a3f380baf4e514072d4d0f0b5d5ccd43b8ce3eb68081eff3d--cmake--3.21.4.arm64_monterey.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git

The solution is as follows:

Running brew -v will give you two prompts to set the file paths for homebrew-cask and homebrew-core to safe.directory, i.e. using the following names.

Follow the prompts

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask

Then executearch -arm64 brew install cocoapods will be OK!

If the above error is encountered, follow the prompts

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-services

Then execute arch -arm64 brew install cocoapods again to succeed.

After successful execution, we execute our installation command againbrew install cmake

Git push error: error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

Problem Description:

the following error is reported during git push:

error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)


Solution steps:
simple solution (restore to HTTP 2 later):

git config --global http.version HTTP/1.1
git push 
git config --global http.version HTTP/2

[Solved] git Error: error: Your local changes to the following files would be overwritten by merge

A git pull error, error: Your local changes to the following files would be overwritten by merge, occurs because changes to the local branch are not saved when git pulls.

There are two general solutions. There is also a special case, that is, the change of permissions such as file reading and writing.

Method 1: discard local changes

If the local modification is not important, you can directly discard the local modification:

# Discard all local uncommitted changes
git checkout .

Some local files are newly added but not Add, the status in git status is untrack , and they need to be deleted through git clean

# First check what files will be deleted
git clean -nxdf

# Make sure the files that will be deleted are correct, then execute the delete
git clean -xdf

# You can also delete files one by one, for example, delete file xxx
git clean -f xxx


Direct execution:

git reset --hard
git pull

Note: discarding local files is a dangerous operation and must be considered before deleting.

Method 2: temporarily store to the stack area

If local modifications are important. If it needs to be used later, the current modification can be temporarily stored in the stack area:

# Staging to the stack area
git stash

# View stash contents
git stash list

To use local modification, apply the stash content to the local branch:

git stash pop

The contents in stash are popped up. If multiple temporary contents are saved, the pop-up order is first in and last out (stack).

If you do not want to pop up the content, but still apply the stash content to the local branch:

git stash apply

In this way, the contents in stash will not be ejected.

In addition, you can manually delete the content in stash

# Delete the contents of a specified stash, the name of which can be obtained from the git stash list
git stash drop xxx
# Delete all stash content
git stash clear


 git stash
 git commit
 git stash pop

Git stash: back up the contents of the current workspace, read the relevant contents from the latest submission, and ensure that the workspace is consistent with the last submission. At the same time, save the current workspace content to the GIT stack
git stash Pop: read the last saved content from the GIT stack and recover the relevant content of the workspace. Since there may be multiple stash contents, it is managed by stack. Pop will read the contents from the latest stash and recover them
git stack list: displays all backups in the GIT stack. You can use this list to decide where to recover
git stack clear: clear the GIT stack. At this time, graphical tools such as gitg will be used to find out which nodes of the original stash have disappeared.

Note: merge after using git stash to temporarily store content, and then git stash pop, branch conflict may be reported. At this time, you can create a new branch locally and recover the stash content on the new branch.

exceptional case:

Git prompts that the file has been modified, but the actual content has not been modified. The reason is that all git libraries will ignore the change of FileMode.

Git diff prompts the change of FileMode, as follows:

git diff xxx
diff --git a/xxx b/xxx
old mode 100755
new mode 100644


#Terminal Execution 
git config --add core.filemode false

[Solved] Mac git clone error:xcrun:error:invalid active developer path(/Library/Developer/CommandLineTools)


After upgrading the MAC system, using git clone and other related commands on the terminal fails with an error

xcrun:error:invalid active developer path(/Library/Developer/CommandLineTools),missing xcrun at:/Library/Developer/CommandLineTools/usr/bin/xcrun


1. Check whether git has been installed

# command
which git

# outcome

Description git has been installed

2. View git help information

git --help

Error reporting is the same as above:

xcrun:error:invalid active developer path(/Library/Developer/CommandLineTools),missing xcrun at:/Library/Developer/CommandLineTools/usr/bin/xcrun

to sum up, GIT has been installed, but the GIT command cannot be used normally. It may be that the GIT installation package is damaged, so reinstall git

3. Reinstall Git

brew install git

The following error messages appear during installation:

Error: The following formula:
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
  xcode-select --install

Error: Git must be installed and in your PATH!
Error: The following formula:
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
  xcode-select --install

according to the prompt, you need to reinstall xcode-select

Solution: install xcode-select

To sum up, we need to reinstall xcode-select and execute the following commands on the terminal

 xcode-select --install

After installation, perform the following:

git --help

The correct output of information indicates that git has returned to normal and can be used


[Solved] Git Clone Error: error setting certificate verify locations


When using git clone to clone an item on GitHub or gitee, the following error is reported:

error setting certificate verify locations:

CAfile: E:/Git/mingw64/ssl/certs/ca-bundle. crt

CApath: none


According to the error prompt, there is an error in setting the certificate verification location, that is, the certificate file path is wrong.

When cloning a remote project, the security certificate will be verified first. If the local security certificate file cannot be found, an error will be reported.

This is why this error will not be reported when cloning projects on gitlab, because gitlab is generally built on the intranet and does not need to verify the security certificate.

Path errors often occur because the local Git is installed green, that is, it is directly extracted and used.

In this way, the path of the certificate file is still the path on the original machine. If the path of the new machine is inconsistent, the path error will be caused.


For the above analysis, there are two solutions:

  • Modify certificate file path (recommended)
  • Turn off certificate verification

Turning off certificate verification may cause security problems. It is recommended to modify the certificate file path.

Modify certificate file path

There are two ways:

  • Execute the configuration command (recommended)
  • Modify the configuration file

The essence of these two methods is to modify the configuration file. However, some misoperations may occur when modifying the file, and the operation is more cumbersome. It is recommended to execute the configuration command.

Execute configuration command

git config --system http.sslcainfo "Git安装路径/mingw64/ssl/certs/ca-bundle.crt"

Modify profile

Git’s system configuration files are located at: git installation path \etc\gitconfig

Modify the path in the file as shown in the figure to git installation path /mingw64/ssl/certs/ca-bundle.crt save again.

Turn off certificate verification

git config --system http.sslverify false

This method may cause git security problems and is not recommended.

[Solved] Gerrit Error: Permission denied publickey

Gerrit reports an error: permission denied solution

Foreword solution


When using the Gerrit clone code, you will find an error. The error message is probably: permission denied (publickey)

openssh has abandoned RSA encryption keys since version 8.8 for security reasons
openssh thinks that RSA cracking costs too little, so it is disabled if there is a risk
you can use the command:
ssh -v [git server]

Check the openssh version number of the Gerrit server.
if it is ≥ 8.8, you can use this method.


Enter the machine SSH directory,
create a new config file without suffix:

The content is:

Host gerrit's IP or domain name
HostName gerrit's IP or domain name
User Gerrit's user name (e.g. zhangsan)
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/id_rsa
Port 29418 (Gerrit port)

Once configured, the clone is OK. Generally, there is no problem.

[Solved] pod CDN: trunk Repo update failed – 56 error(s):

pod CDN: trunk Repo update failed – 56 error(s):

An error is reported when performing pod install: (reason for this problem: cocoapods 1.8 switches the CDN to the default spec repo source)

[!] CDN: trunk Repo update failed - 56 error(s):

1. Check the version number to see if the version is 1.8 or later

pod --version

2. Remove trunk

pod repo remove trunk

3. Enter this directory

cd ~/.cocoapods/repos

4. Execute command

git clone --depth 1 https://github.com/CocoaPods/Specs.git master

5. Here you are. Just execute pod install again.

Error: Host Key Verification Failed [How to Solve]

Delete the previous GitHub account information (including the deletion of the file under. SSH and the modification of user, name and user.email), reuse the new GitHub account to generate the public-private key, and then configure it into the settings of the new GitHub account. After that, an error is reported in the GIT clone project. Git error: host key verification failed

Open git bash

Enter the following commands in sequence to solve the problem

mkdir -p ~/.ssh
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
ssh-keygen -t rsa -C "user.email"

Reference: stackoverflow