Tag Archives: git

Git Error: fatal: remote origin already exists.

Today, when using git to add a remote GitHub warehouse, you will be prompted with an error: fatal: remote origin already exists

Finally, the solutions are as follows:
1. Delete the remote git warehouse first

$ git remote rm origin

2. Add remote git warehouse

$ git remote add origin [email protected] :FBing/java-code-generator

If an error is reported when git remote RM origin is executed, we can manually modify the contents of the gitconfig file

$ vi .git/config

git:fatal: No configured push destination.

An error is reported when the local warehouse code (GIT push) is uploaded to the GIT warehouse:

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

Solution:
create a new warehouse in Git warehouse and copy the warehouse URL link:

git remote add origin https://github.com/xxxxx/xxxxx.git

git push -u origin master

Idea uses git’s pull command to report error 1

Reference blog: https://blog.csdn.net/nan7_/ article/details/25624637

Your local changes would be overwritten by merge. Commit, stage or revert them to proceed

Cause: git conflict

1. Use the GIT repository stash changes command to save your changes

At this time, you will find that the modified parts are gone and return to the original state

2、pull

Download the code on GIT

3、git-repository-Unstash changes

Take out your own code and compare and merge the code

In the comparison page, the version in Git library is on the left, the original version is in the middle, and your own version is on the right

Git error: requested URL returned error: 403

Execution error:

[root@localhost learngit_2]# git remote add origin https://github.com/shengleqi/gitskills.git
[root@localhost learngit_2]# git push -u origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/shengleqi/gitskills.git/info/refs

fatal: HTTP request failed

Repair method:

You can see the bold red text above ( the requested URL returned error: 401 authorization required ), which is caused by a permission problem. You can modify the. Git/config file and add a user name and password:

1) Edit the. Git/config file

2) Find the URL variable under [remote “origin”]

3) Modify URL= https://github.com/user/test.git , modify to URL= ssh://git @Github.com/user/test.git, save after modification

4) Synchronization through git push origin master is successful

Amend as follows:

[root@localhost learngit_2]# cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url =  ssh://[email protected]/shengleqi/gitskills.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

Successful execution:

[root@localhost learngit_2]# git push -u origin master
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?yes
Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
Counting objects: 26, done.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (26/26), 2.08 KiB, done.
Total 26 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), done.
To ssh://[email protected]/shengleqi/gitskills.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

 

Git submission error self signed certificate

Git submission error: fatal: unable to access’ http:. Git/’: SSL certificate problem: self signed certificate     Git failed to end successfully (exit code 1)  

Solution:

In Git   Running git in Bash   Built in configuration command Git   config  — global   http.sslVerify   False (turn off the security carefully) and submit again

 

Error reported in vscode after installing Git

After installing git, an error is reported in vscode that git cannot be found:

Find git in C:/program files/git/bin/git.exe

Find git in C: \ program files \ git \ CMD \ git.exe

Find git in C: \ program files (x86) \ git \ CMD \ git.exe

Find git in C: \ program files \ git \ CMD \ git.exe

Find git in C: \ users \ administrator \ appdata \ local \ programs \ git \ CMD \ git.exe

Git installation not found.

 

Then find the GIT directory and open the two files:

Enter git — version in CMD, and the same error will be reported:

Microsoft Windows [version 10.0.16299.15]

(c) 2017 Microsoft Corporation。 All rights reserved

  C:\windows\system32> git -version

fatal: open /dev/null or dup failed: No such file or directory

Solution:

The reason I found it on the Internet is that there is a problem with the null.sys file under C: \ windows \ system32 \ drivers, so I found another null.sys on the network disk to replace the original one, and then restart the computer

Network disk address of null.sys https://pan.baidu.com/s/1kwKmnHSBjfonHUFenveXAA (it can also be found in my network disk – related GIT). Of course, this solution is limited to win10

(also, the command used to check the GIT version is: git — version, with two bars)

[Solved] Git stash pop Error: Another git process seems to be running in this repository……

 

summary

When developing new functions in the dev development branch, there is an emergency bug in the master branch that needs to be fixed. The command git stash can temporarily store the code changes of the current dev branch and switch to the master branch to solve the emergency bug. Today, I encountered a git error message that I restored the temporary code after switching back to the dev development branch, but the code could not be submitted after restoration, resulting in Git process conflict. The specific error information is as follows:

 Another git process seems to be running in this repository, e.g.an editor opened by ‘git commit’. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

After the research on the solution of error information, we found a specific and effective solution

solutions

Main idea: git process has been opened in an editor. Please make sure all processes are finished before trying. If it still fails, git in the last run may crash. Please remove this file manually before continuing

1. Nature of the problem: 

Windows has a lock mechanism for process management. Under normal circumstances, the process runs = = > Process lock = = > Process end = = > The process is unlocked. Maybe I accidentally shut down git while switching branches, which led to git crash, so the locked index.lock didn’t unlock, resulting in conflict

2. Solution: 

Open the project folder and find the index. Lock file in the. Git file. The file that needs to be manually deleted in the error message is the index. Lock file. After deleting, go back to GIT and continue to operate the command, which perfectly solves the conflict problem of GIT process

summary

When operating git command, we need to pay attention to the status of GIT process. The most important thing is that we need to be careful when operating git command. Even when we encounter urgent tasks, we need to be calm to solve them. We can’t eat hot tofu if we are anxious

Could not create directory ‘/ /. SSH’ when installing Git

Website content quality is poor, distribution efficiency is too low how to do?Huawei engineers offer 5 unique skills>>>

After installing git in window, generate SSH key in CMD. Use SSH keygen

During the command, I was prompted with the error of “could not create directory ‘/ /. SSH”. My colleague said that he had encountered the same error before, which was caused by the lack of system variables. At that time, he helped me add the variables, but I didn’t see which variable was added. Today, I looked up the information on the Internet and found out that the environment variable of home was added. My job is to add home = C/users. Then skills are generated automatically. Excerpt【

Digression: because it’s a Windows environment, it may have been affected when cygwin was installed a few days ago

In addition, in the actual use process, we found that although cygwin imitates the Linux environment under windows, in many cases, there will be obscure problems, and there is no error prompt. For example, this time, using the command line of cygwin and git, everything else is normal, but when submitting the code, it will lose its response (not stuck, but after entering, it will not submit the code and there is no output) and there is no error prompt. Finally, it’s done with the built-in CMD of windows

)】

In addition, the note I learned is the misunderstanding of GIT. I used to think that Git is GitHub, but I learned that they are different concepts through video learning. Git is actually more like a technology, and GitHub is a platform to provide the use of this technology

Environment: Windows 7 ultimate

Git Permission issues: insufficient permission for adding an object to repository database .git

Error in Git pull: invalid permission for adding an object to repository database. Git

(go to the object folder in the warehouse and execute Chmod 777 – R *)

Git made a mistake in pull. The situation is as follows:

[lixinglei@bogon my]$ ll -a|grep .git  
drwxrwxr-x.  8 lixinglei lixinglei 4096 Jun   6 19:58 .git  
-rw-rw-r--.  1 lixinglei lixinglei  109 Apr  23 14:02 .gitignore  
[lixinglei@bogon my]$ cd .git  
[lixinglei@bogon .git]$ cd objects/  
[lixinglei@bogon objects]$ ll | grep root  
drwxr-xr-x. 2 root      root      4096 May  27 19:37 3b  
drwxr-xr-x. 2 root      root      4096 May  27 19:37 68

According to the error prompt, it is found that there is a problem with the ownership of some files under “. Git/objects”:

[lixinglei@bogon my]$ git pull [email protected]:XXX.git  
remote: Counting objects: 29, done.  
remote: Compressing objects: 100% (22/22), done.  
remote: Total 22 (delta 17), reused 0 (delta 0)  
error: insufficient permission for adding an object to repository database .git/objects  
  
fatal: failed to write object  
fatal: unpack-objects failed

Log in as root and enter the directory:

[root@bogon objects]# ll | grep root  
drwxr-xr-x. 2 root      root      4096 May  27 19:37 3b  
drwxr-xr-x. 2 root      root      4096 May  27 19:37 68  
[root@bogon objects]# chown lixinglei: 3b  
[root@bogon objects]# ll | grep root  
drwxr-xr-x. 2 root      root      4096 May  27 19:37 68  
[root@bogon objects]# chown lixinglei: 68  
[root@bogon objects]# cd 68  
[root@bogon 68]# ll  
Totally 4  
-r--r--r--. 1 root root 213 May  27 19:37 cb6ab3332e342158b1b27341a2c396cd570a4c  
[root@bogon 68]# chown lixinglei: cb6ab3332e342158b1b27341a2c396cd570a4c  
[root@bogon 68]# cd ../  
[root@bogon objects]# cd 3b  
[root@bogon 3b]# ll  
Totally 4  
-r--r--r--. 1 root root 1647 May  27 19:37 d60abd850ecacb4002ed870176172426f662d2  
[root@bogon 3b]# chown lixinglei: d60abd850ecacb4002ed870176172426f662d2  

How to deal with git file damage caused by sudden shutdown

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)
$ git status
On branch develop
error: inflate: data stream error (unknown compression method)
error: unable to unpack e77ede4f4eb99996e9312a9e8f231d1fc3558db0 header
error: inflate: data stream error (unknown compression method)
fatal: loose object e77ede4f4eb99996e9312a9e8f231d1fc3558db0 (stored in .git/objects/e7/7ede4f4eb99996e9312a9e8f231d1fc3558db0) is corrupt

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)
$ git show 831a5d31af4a0af2f5a367689bee27a44efc22c9 > 831a5-file^C

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)
$ git show e77ede4f4eb99996e9312a9e8f231d1fc3558db0 > 831a5-file
error: inflate: data stream error (unknown compression method)
error: unable to unpack e77ede4f4eb99996e9312a9e8f231d1fc3558db0 header
error: inflate: data stream error (unknown compression method)
fatal: loose object e77ede4f4eb99996e9312a9e8f231d1fc3558db0 (stored in .git/objects/e7/7ede4f4eb99996e9312a9e8f231d1fc3558db0) is corrupt

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)
$ ls .git/objects/e7/7ede4f4eb99996e9312a9e8f231d1fc3558db0
.git/objects/e7/7ede4f4eb99996e9312a9e8f231d1fc3558db0

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)
$ rm -rf .git/objects/e7/7ede4f4eb99996e9312a9e8f231d1fc3558db0

Administrator@wangxinqiang-PC MINGW32 /d/juejinqifu (develop)