Tag Archives: git

Git prompt error setting certificate verify locations solution

Question: Use git extension to pull or push code, prompt

“C:\Program Files\Git\bin\git.exe” pull –progress “origin” +refs/heads/zjw
fatal: unable to access’https://github.com/**/ ‘: error setting certificate verify locations:

CAfile: C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt
CApath: none
Done

Press Enter or Esc to close console…

This is because git requires security certification when submitting code, which can be set by the following method to cancel the verification

solve:

Find the git config configuration file, the path should be
C:\ProgramData\Git\config, add the following two lines

[http]
sslVerify = false
sslCAinfo = /bin/curl-ca-bundle.crt

After saving, submit the code again.

Solve the problem of “error: error fetching remote repo ‘origin'” in Git on Jenkins

What are the eight life cycle hook functions of Vue>>>

solve the problem of “error: error fetching remote repo ‘origin'” in Git on Jenkins

Reference article:

(1) Solve the problem of “error: error fetching remote repo ‘origin'” in Git on Jenkins

(2) https://www.cnblogs.com/feng0520/p/9070071.html

Let’s make a note.

Git exception: fatal: could not create work tree dir’XXX’: No such file or directory

DNT@DESKTOP-PTACRF6 MINGW64 ~/Windows10 (master)
$ git clone [email protected]:dunitian/IPToPosition.git
fatal: could not create work tree dir’IPToPosition’: No such file or directory

Look at the path of the execution directory==>~/Windows10 (master)

 

Switch to the root directory: cd ~

 

Enter the command again and it’s ok

DNT@DESKTOP-PTACRF6 MINGW64 ~
$ git clone [email protected]:dunitian/IPToPosition.git
Cloning into’IPToPosition’…
Warning: Permanently added the RSA host key for IP address ‘192.30.252.130’ to the list of known hosts.
warning: You appear to have cloned an empty repository.
Checking connectivity… done.

Conflict resolution after git error non fast forward

When the code is to be pushed to git, a prompt appears.

error:failed to push some refs to …

Dealing with “non-fast-forward” errors
From time to time you may encounter this error while pushing:

$gitpushoriginmaster

To../remote/

![rejected]master->master(non-fastforward)

error:failedtopushsomerefsto’../remote/’

To prevent you from losing history, non-fast-forward updates were rejected

Merge the remote changes before pushing again. See the ‘non-fast forward’

section of ‘git push –help’ for details.

This error can be a bit overwhelming at first, do not fear. Simply put, git cannot make the change on the remote without losing commits, so it refuses the push. Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.

In other cases this error is a result of destructive changes made locally by using commands like git commit –amend or git rebase. While you can override the remote by adding –force to the push command, you should only do so if you are absolutely certain this is what you want to do. Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.

The reason for the problem (Non-fast-forward) is that the git repository already has some of the code in it, so it doesn’t allow you to overwrite your code directly. So you have 2 options.

1, force-push, which replaces the git repository with your local code using a strong override

git push -f

2, fetch the git stuff to your local repository and then merge it and then push it

$ git fetch

$ git merge

These two commands are equivalent to

$git pull

But then you have the following problem.

The [branch “master”] that appears above is required to be explicit (.git/config) as follows

[branch “master”]

remote = origin

 

merge = refs/heads/master

This tells git 2 things:

 

1, when you are on master branch, the default remote is origin.

2, when you use git pull on master branch without specifying remote and branch, then git will use the default remote (that is, origin) to merge all changes on master branch

 

If you don’t want to or don’t know how to edit the config file, you can type the following command line on bush.

$gitconfigbranch.master.remoteorigin

$gitconfigbranch.master.mergerefs/heads/master

After that, git pull again. Finally git push your code.

it works now~

git:Pull is not possible because you have unmerged files [How to Solve]

git:Pull is not possible because you have unmerged files

Local push and merge will form references such as merge-head (fetch-head) and head (push-head). Head represents the reference formed after the local successful push. Merge-head represents the reference formed after successful pull. You can use merge-head or head to achieve the effect of type and svnrevent

Solution:

1. To flush out local conflict files, not only reset to merge-head or head, but also — hard. Without the hard in the back, it won’t flush out the local workspace. It just washes out the stage area

git reset--hardFETCH_Head

2. Gitpull will succeed

[Solved] Computer reboot causes broken git files

 

Error 1.
	error: bad signature
	fatal: index file corrupt
Cause.
	The index file is generally referred to as .git/index in git. This file holds information about the staging area (index information). You can see the contents of the staging area by using git ls-files --stage. This file is very important! But now it says index file corrupt, which means the file is corrupt. Fortunately, there is a way to regenerate this file: git read-tree or just git reset.
The solution.
	1. Delete or rename the .git/index file. rm -f .git/index
	2. git reset

	Solved the first problem, I thought it would be good, excited to operate again, git status appears all green files, I thought it was all to recommit under it, did not take it seriously, until I git commit when I encountered a fatal, can not go on, again oriented to Baidu.
Error 2.
	fatal: cannot lock ref 'HEAD': unable to resolve reference 'refs/heads/master': reference broken
Cause.
	Probably a computer reboot during push, resulting in a damaged git file.
Solution.
	I borrowed this method from someone else: remotely recheck out the project to a new folder, copy the new project's .git folder completely to the folder where the error occurred, and then commit and push again.

 But I wasn't as lucky as the blogger I borrowed from, and the next thing I knew, my code ...... conflicts, and the last thing I want to encounter is a conflict.
Error 3.
	Automatic merge failed; fix conflicts and then commit the result
Solution.
	emmm, you can download a Visual Studio Code to solve the conflict.

Git | fatal: refusing to merge unrelated histories [How to Solve]

Scenario: create an empty warehouse in gitee and push the existing warehouse. Through remote add origin < git path> specified warehouse, error message: error: failed to push some refs to ' https://gitee.com/XXXX/XXXXX.git ' Terminal Information:

JerrydeMacBook-Pro:web-h5 jerrylam$ git push      
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

After executing git push --set-upstream origin master, it reports another error, as follows .

JerrydeMacBook-Pro:web-h5 jerrylam$ git push --set-upstream origin master
To https://gitee.com/XXXX/web.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/XXXX/web.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Try git pull origin master , the error message is as follows

JerrydeMacBook-Pro:web-h5 jerrylam$ git pull origin master
From https://gitee.com/XXXX/web.git
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Solutions

# Change the previous git pull origin master to the following code

git pull origin master --allow-unrelated-histories

Finally, we can push it

JerrydeMacBook-Pro:web-h5 jerrylam$ git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 3.77 KiB | 3.77 MiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/XXXX/web.git
   f6b4cf0..c538ad9  master -> master

When push doesn’t go up, first git pull ensures the latest code

git pull  --allow-unrelated-histories
# Or specify branches
git pull origin master --allow-unrelated-histories