Error “‘git’ is not recognized as an internal or external command”

You may not have set your PATH correctly to point at your Git installation. You need to add the following paths to PATH: C:\Program Files\Git\bin\ C:\Program Files\Git\cmd\ And check that these paths are correct. You may have Git installed on a different drive, or under Program Files (x86). Correct the paths if necessary. Modifying PATH … Read more

Can I view the reflog of a remote (not remote ref)?

On the off chance that the remote machine is a github repository, First use Github’s Events API to retrieve the commit SHA. curl https://api.github.com/repos/<user>/<repo>/events Identify the SHA of the orphan commit-id that no longer exists in any branch. Next, use Github’s Refs API to create a new branch pointing to the orphan commit. curl -i … Read more

Git is not working after macOS update (“xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools”)

The problem is that Xcode Command-line Tools needs to be updated due to OS update. ** UPDATED for Ventura and updated apple dev download page ** After opening the terminal after a restart, I tried to go to my code, and do a git status, and I got an error and prompt for command line … Read more

How do you detect an evil merge in git?

The easiest thing to do would be to diff the results of your conflict resolution with a merge that auto-resolves conflicts without human intervention. Any automatic resolutions will be ignored, since they will be resolved in exactly the same way. I see two ways of visualizing the possible “evil” resolutions. If you are making this … Read more

How to compute the git hash-object of a directory?

Depending why you wish to do this, the following git command might be useful: git ls-files -s somedirectory | git hash-object –stdin This give a single hash which takes into account the filenames and contents. It works like this. The git ls-files -s …. outputs a list of files and their hashes as text to … Read more

Git: untrack a file in local repo only and keep it in the remote repo

You could update your index: cd /root/folder/of/your/repo git update-index –assume-unchanged nbproject/project.properties and make sure it never shows as “updated” in your current repo. That means it won’t ever be pushed, but it is still present in the index. (and it can be modified at will in your local working tree). to revert that state (from … Read more

How to invert `git log –grep=` or How to show git logs that don’t match a pattern

This will be possible with Git 2.4+ (Q2 2015): see commit 22dfa8a by Christoph Junghans (junghans): log: teach –invert-grep option “git log –grep=<string>” shows only commits with messages that match the given string, but sometimes it is useful to be able to show only commits that do not have certain messages (e.g. “show me ones … Read more