Tag Archives: Git error

[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] Git Error: fatal: refusing to merge unrelated histories

If you merge two different repositories for starting submission, you will find that the two repositories may not be the same in the new GIT. In order to prevent developers from uploading errors, you will give the following prompt

Git cannot pull warehouse refusing to merge unrelated histories

The problem is usually caused by the inconsistency between the local warehouse and the remote warehouse after the new warehouse is built,

Solution: add --allow-unrelated-histories after your operation command. Its original purpose is to remind you that these are two different libraries It’s time to merge.

If you are other command messages fatal: refusing to merge unrelated histories add – -allow unrelated histories in the same way, it is such a perfect solution!

[Solved] Git Error: fatal: refusing to merge unrelated histories

1. Problem

fatal: refusing to merge unrelated histories

2. Scene

Merge other branches into master branch

3. Reason

The two branches are two different versions with different commit histories, so an error is reported.

4. Solutions

Allow unrelated historical commits and force merges, the code is as follows:

git pull origin master --allow-unrelated-histories

How to Solve Git Error: error: unable to unlink old ‘***.jar‘

1 problem description

When a new branch code (GIT fetch + git checkout – b) is pulled to operate a new local branch, there is a problem (GIT rebase, GIT stash, GIT checkout old branches will not prompt this error, and the same error will be reported on rollback on idea)

2 problem solving

Stop the application (the project is running, and the jar package is referenced, which makes git unable to access). Rollback the jar package in the idea, select the jar package, and click the button

3 problem analysis

The project is running, the jar package is referenced, and git cannot be updated

How to Solve Git error: out of memory

Question

No matter pull, clone or push, errors are reported

fatal: Out of memory, malloc failed (tried to allocate 301989888 bytes)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Solution:

git config --global http.postBuffer 524288000
git config --global core.compression -1

How to Solve Git Error: error: failed to push some refs to……

Error message:

error: failed to push some refs to '[email protected]:....." Updates were rejected because the remote contains work that you do not have locally.
This is usually caused by another repository pushing to

Cause analysis:

1. This error may occur when using git to push the source code to GitHub

2. The main reason for the error is that the readme.md file in GitHub is not in the local code directory

Solutiont:

Method 1: pull it down first and it will merge automatically (don’t worry)

Command: git pull origin master

Method 2: Code merging can be carried out through the following commands

Command: git pull — rebase origin master (my successful solution is method 2)

Finally, execute the statement git push to upload the code to GitHub

Command: git push – U origin master

[Solved] Git Error: client_global_hostkeys_private_confirm: server gave bad signature for RSA key 0

Error message:

client_ global_ hostkeys_ private_ confirm: server gave bad signature for RSA key 0

Client \ global \ host key \ private \ confirm: the server provided the wrong signature for RSA key 0

When I submit git using the following instruction

git add .
git commit -m 'feat :Push'
git push origin

Solution:

Scheme 1: make sure your ~ /. SSH/config contains the following:

Host gitlab.com
UpdateHostKeys no

Scheme 2: try regenerating the public-private key

Git error: unpack failed: error Missing tree [How to Solve]

I recently created a new warehouse and encountered the following problems when I pushed it. I tried many methods and finally found a solution on stackoverflow, but I tried this method at the beginning, but it didn’t work. As for why this error occurred, I still don’t understand the reason.

git.exe push –progress  “origin” release:refs/for/release%r=xxx

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 663 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: unpack failed: error Missing tree 4201fba85e02299e016f0129621858ec21ac94ae
To (url)
! [remote rejected] release -> refs/for/release%r=xxx(n/a (unpacker error))
error: failed to push some refs to ‘(url)’

git did not exit cleanly (exit code 1) (593 ms @ 2015/5/15 9:51:12)

 

Solution: git push –no-thin origin HEAD:refs/for/release

[Solved] Git error: You have not concluded your merge (MERGE_HEAD exists)

Enter the root directory of the website

Solution 1: keep the local changes and stop merging – & gt; Re merge – & gt; Pull again

$:git merge --abort
$:git reset --merge
$:git pull

Solution 2: discard the local code, and the remote version will cover the local version (be careful)

$:git fetch --all           //Repulling
$:git reset --hard origin/master //git reset --hard reverts master back to origin/master and ignores all new commits
$:git fetch

git remote: HTTP Basic: Access denied error resolution

git error: git remote: HTTP Basic: Access denied

Cause of the problem: it may be that the password of the remote warehouse has just been changed, resulting in the inconsistency between the user name and password of the local git configuration and the user name and password registered on gitlab.

1. Solution 1:

Follow the steps shown in the figure

Then continue to use soucetree, you will be prompted to enter the user name and password

2. Solution 2:

If the account password changes, use the following command to re-enter the account password

git config –system –unset credential.helper

If the problem cannot be solved with the first command, enter the following command again:

git config –global http.emptyAuth true