Install Git on Mac without Xcode - xcode

I've been using windows for software development. I'm not aware of MacOS internals.
I'm aware that Xcode software is used to develop iOS/Mac apps but I don't need it.
For my usecase, I was able to install intellij, Java, Docker, Minikube & Visual-Studio-Code on my Intel Mac with BigSur...
I'm able to run simple micro-service with working DB in local in docker container.
But when I try to use Git I'm getting this issue:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
I think this is related to Xcode. I didn't want to touch it,
so I tried to install Git by brew.
brew install git but got error
Error: git 2.29.2 is already installed
So I tried to do update
brew upgrade git but again got the below error again.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
I also tried to remove Git to do a clean install
brew remove git and there was no error, but then I installed git with brew again and the same error.
Is there a way to install Git without having Xcode ?
I dont want to install unnecessary software on my machine, things which I don't need.

Note that this is a plain copy of a previous answer of mine on superuser.com.
Here's a way to install git on Mac OS X without XCode.
Git's official web site provides an installer : http://git-scm.com/download/mac
After installing git, you also have to add its directory to your path :
echo "PATH=/usr/local/git/bin:\$PATH" >> ~/.bash_profile
source ~/.bash_profile
Adding the directory to the path will prevent Mac OS X from aksing you to install XCode each time you type git in the terminal.
Credits goes to Bobby Allen and to GoZoner's answer on SO.

What you need is not xcode but xcode command line tool which has a small download and running file space compared to xcode of 11GB download space and running space of 31GB
You can download it from apple at https://developer.apple.com/downloads/

Related

Brew install on Mojave

I did these steps:
Updated to Mojave
Installed Xcode 10 beta3
Ran this command: sudo xcode-select -switch /Applications/Xcode-beta.app/
Now I'm trying to install node8:
brew install node#8
And it gives me this error:
Error: The Command Line Tools header package must be installed on Mojave.
The installer is located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Still, doing
install -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
does nothing, since there's no such file in my system. Where could I get it?
Go to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg location and install package manually. And brew will start working.
I want to try and answer this question and also for those that come later that installed Mojave and had an older Xcode version installed. The process is the same minus that if you have Xcode 10, you don't need to install it again from my understanding.
The folder is hidden and was not accessible even with a sudo find command, however, I figured out that copying the absolute path and then pasting it in your browser address bar will give you the download and access to the folder that you need to fix brew install.
I posted a video here- https://youtu.be/GfnhSirTCGM that walks you thru part of my steps above. After you do the SDK headers download, its likely that unless you already are running Xcode 9.4, you will need to visit, https://developer.apple.com/download/more/ and look for Xcode 9.4 to install. Also grab the 10.14 command line tools as well. The lesson that should be learned here is that Apple calls it "Beta" for a reason and if you are a developer that knows the pains of setup, it is a bad idea. I hope that I was helpful! The last thing is, INSTALL XCODE THEN COMMAND LINE TOOLS-IN THAT ORDER OR IT ERRORS OUT! and then we do this all over again. Cheers!
It appears as though Apple has released a patch for the bug and it is available through the system preferences. 14 July 2018
Broken command line tools:
Xcode Location on the Apple developers website:
Location of command line tools:
Do not install Xcode from the Mac App Store because a different version is required!
Command line tools 10.14 update:
As of October 2018, the solution for making brew and brew install succeed is to:
install latest Xcode fom AppStore
run Xcode and install command line tools
add the line before to your profile or somethign similar
export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
No need to download Xcode manually, but you may want to remove the beta version if you installed it.
The magic part is at the end, where xcrun obtains the correct location of the SDK.
In terminal, you should first input the commands below
cd /Library/Developer/CommandLineTools/Packages
open .
you will open the directory on desktop,
then double click the pkg file to install it.

How to continue using Git on mac after uninstalling Xcode (with Android Studio)?

I have installed Git on my Mac. When I do a "whereis" in my terminal the route is:
/usr/bin/git
I use Android Studio and the GitHub desktop client and had no problems so far.
Previously I had installed Xcode, but I uninstalled it a week ago. Since then, Android Studio does not detect Git, I get the following error:
xcrun: error: active developer path
("/Volumes/Vega/Applications/Xcode.app/Contents/Developer") does not
exist, use xcode-select --switch path/to/Xcode.app to specify the
Xcode that you wish to use for command line developer tools (or see
man xcode-select)
Android Studio shows the same executable path to Git
indicating the terminal (/usr/bin/git), but when I click on the "test" button it displays the same error.
I do not handle very well Git from the terminal, always use the desktop client.
What do I have to do to continue using Git on my Android studio (or anywhere) now that I uninstalled Xcode?
I searched for information but I can not fix it.
If commands sudo xcode-select --reset and xcode-select --install does not work for you and you dont want to install xcode then just reinstall git manually via brew:
brew reinstall git
And open new terminal session
Worked for me
sudo xcode-select --reset
Will reset your paths to the defaults if the command line tools are already installed.
You should install the Xcode command line tools at the very least. If you're not a registered Apple Developer, however, I'm not sure how to get hold of them if Xcode is not installed. If you are a registered Apple Developer, you can get them from the Apple Developer Download site. It' probably best to re-install Xcode and you will get them as a system update.
That will give you a minimal development environment, and if you need additional tools/libraries you can build them via Macports with the command line tools installed.
Try this :
xcode-select --install

Git not working. Installed XCode

Using an iMac running OSX 10.8.5 (Mountain Lion). It's a work computer and can't upgrade to a higher OS version at the moment for various reasons.
I tried installing XCode so that I can use Git but it isn't working.
In terminal I run:
git --version
and get this response:
-bash: git: command not found
What am I doing wrong?
You need to install git separately:
http://burnedpixel.com/blog/setting-up-git-and-github-on-your-mac/
Source control was only introduced into Xcode 4. This however does not mean git is installed onto your system as part of downloading Xcode. It just means that you can use some git features in a Xcode project by pressing the source control button at the top. To install the actual git go here.
I'm don't know why it appears to be so, but it looks like Git still isn't installed on your computer. Another way to check if Git is installed is by using the which git command. If that still doesn't help, install it separately. Download Git for Mac.

Reasons why git is not visible to Rstudio (OSX)

I have been trying for a few hours to use git within Rstudio on my macbook. However, the option to use git within version control is missing - the only option remains (none).
I have installed github, and then git directly, using the link given
in the rstudio website.
I have attempted to run the bash script
supplied with the git installation file.
I have verified that git is
active on the machine through both github and directly through the
command line.
I have located the git file in the hidden folder
/local/git/bin/git
and pointed Rstudio to this using global options.
I have reinstalled git a couple of times.
I have logged off and on again multiple times.
Any solutions very welcome.
Thanks,
Jon
The same just happened on my mac. I narrowed down the issue to the Xcode developers package update. The fix in my case was:
From a shell go to /usr/bin
sudo ./git
Agree to the terms
Close and reopen RStudio
VoilĂ . Git has returned to RStudio.
My RStudio git tab disappeared after upgrading to OS X El Capitan. I tried following the advice in the top answer:
but I got the error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
which led me to discover I had to reinstall XCode command-line tools. I did this via:
xcode-select --install
I also updated to latest release of RStudio. Then my git tab reappeared.
I just came across your question after I encountered a similar issue on windows. You've probably sorted yourself by now but just to let you & others know what worked for me.
From RStudio Tools, Global Options.
Option for Git Executable.
Browsed to git.exe in the git/bin folder.
Now working like a dream.
Andy
It's now working. As expected it took re-installing the operating system, as well as the following:
http://blog.rstudio.org/2013/10/22/rstudio-and-os-x-10-9-mavericks/
Using the preview version available from the link below solved the Rstudio/Git issue instantly.
Same issue with OSX High Sierra
This answer in this thread on GitHub helped me
In short, OSX seems to use another directory for the git file

Xcode and Git installation on MacOSX Mountain Lion

I just installed Mountain Lion and Xcode, so under /Applications/Xcode.app/Contents/Developer/usr/bin I found the Git directory
But when I use Git commands in the shell terminal it returns error of command not found. Any suggestions? I have many Git repos on my mac, so I would like to reuse them without checking them out again :/
You need to install the command line tools (see Xcode -> Preferences -> Downloads) or you can download it from the Apple Developer Download site.
First of all, installing the Xcode Command Line tools is probably not what you want. See this post for more information:
http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
You want to set up symbolic links or aliases that point to the versions of git (and svn etc.) that exist inside Xcode.app. This will cause you to automatically get newer versions when Xcode updates through the app store. Installing the command line tools will only confuse matters because you will end up with multiple versions of git lying around, and you will have to manually update the command line tools.
The commands you will need are:
sudo xcode-select --switch /Applications/Xcode.app # tells 'xcrun' where to look
And then in your shell profile, for example .bash_profile:
alias git='xcrun git' # use 'xcrun' to locate the git binary
Now running 'git' from the terminal will use the latest version inside Xcode.app.

Resources