Tag Archives: git

error: src refspec master does not match any [How to Solve]

When you use the git bash command to upload items to github, you always encounter some errors that cannot be resolved.

Here is a problem I encountered

error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:hahaha/ftpmanage.git'

Question content:

Error: SRC ReFSPEC master does not match any
Error: Failed to push some references to ‘git @ Github. com: HaHaa/ftpMal git’

That is, the warehouse is empty.

Solution:

Use git add xxx.py command adds all files, and then use command git commit -m “init” to commit all files,

git commit -m "init"

Then execute

git remote add origin xxxxxxxx.git

Last use

$ git push -u origin master

be accomplished.

Summary:

In fact, only the following steps are needed to upload the local project to Github

 1. create a local repository (i.e. folder) and turn it into a Git repository by git init.

 2. Copy the project into this folder and add it to the repository via git add . Add the project to the repository.

 3. commit the project to the repository by using git commit -m "comment content".

 4, after setting up the SSH key on Github, create a new remote repository by git remote add origin https://github.com/guyibang/TEST2.git Associate a local repository with a remote repository.

 5, and finally push the local repository project to the remote repository (that is, Github) through git push -u origin master; (if the new remote repository automatically created a README file will report an error, the solution see above).

 

[Solved] OCI runtime create failed: runc create failed: unable to start container process:

OCI runtime create failed: run create failed: unable to start container process: exec: “env”: executable file not found in $PATH: unknown

The above error occurs when running the docker container.

Reason:
The image given to me by others has been decompressed, and I was told that I used load to load the image.

docker load < ***.tar

The command reports an error
The error message is: open/var/lib/locker/tmp/locker import - **************/repositories: no such file or directory.

So I used docker import to load the image, and surprisingly it loaded successfully, and there was no problem of 0kb as mentioned on the internet.

docker import ***.tar docker:v1

But there was a problem at runtime.

docker run

The following error message appears:
Error response from daemon: failed to create shim task: OCI runtime create failed: run create failed: disable to start container process: exec: "env": executable file not found in $PATH: unknown

Solution:

tar -xvf	***.tar

After decompression, load the image again. Success!

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

Reason:

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

Soution:

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

Or

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

Generally:

 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

Solution:

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

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

Background

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

Troubleshooting

1. Check whether git has been installed

# command
which git

# outcome
/usr/local/bin/git

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:
  git
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:
  git
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

Description

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

analysis

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.

Solution:

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

Foreword

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.

Solution

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

Solution:
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