Git on macOS, xcrun: error: invalid active developer path

After upgrading to macOS Big Sur 11, macOS Monterey 12, macOS Ventura 13, etc. Does it seem every upgrading macOS will cause the following error message for the git command? How to fix it? Terminal % git xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Solution Open the Terminal, and run this …

Read more

SSH – Load key “/Users/username/.ssh/id_rsa.pub”: invalid format

Suddenly the git push via SSH failed, and the remote server returned something like invalid format for the public key id_rsa.pub? Terminal git push Load key "/Users/username/.ssh/id_rsa.pub": invalid format [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Last week, …

Read more

GitHub keep asking for username password when git push

git clone one of my existing repo (with SSH key added in the Github), modified some files and tried to git push, and it keeps asking for username and password for git push operation? Terminal git push Username for ‘https://github.com’: Password for ‘https://github.com’: GitHub authentication is successful. Terminal ssh -T [email protected] Hi mkyong! You’ve successfully …

Read more

Git – Unable to resolve reference ‘refs/remotes/origin/master’: reference broken

A git pull and hits the below "reference broken" error message? Terminal $ git pull error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference ‘refs/remotes/origin/master’: reference broken From bitbucket.org:xx/mkyong-tutorials ! [new branch] master -> origin/master (unable to update local ref) Solution Unsure the root cause of the "reference broken". To fix it, delete this file …

Read more

Git pull – refusing to merge unrelated histories

Add –allow-unrelated-histories to solve the Git fatal error – “refusing to merge unrelated histories” Terminal $ git pull origin master From https://github.com/mkyong/java-concurrency * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories To fix it : Terminal $ git pull origin master –allow-unrelated-histories From https://github.com/mkyong/java-concurrency * branch master -> FETCH_HEAD Merge made by the …

Read more

Git – How to undo the last commit?

In Git, we can use git reset –soft HEAD~1 to undo the last commit in local. (The committed files haven’t pushed to the remote git server) 1. Case Study git commit and find out some unwanted target/* files are committed accidentally, I haven’t issue the git push, any idea how to undo the commit? Terminal …

Read more