Updating Git from Version 1.9.0 to 2.2.1 - macos

My console recently made me aware that the git version I have installed on my Mac has various security flaws and I was advised to upgrade.
I don't know how to use homebrew so I have gone for an easier option. I was recommended to download the following installed by git-scm.com
http://sourceforge.net/projects/git-osx-installer/?source=typ_redirect
I have installed the package but my terminal still shows:
MacBook-Pro-3:~ mruser$ git --version
git version 1.9.0
MacBook-Pro-3:~ mruser$ which git
/usr/local/bin/git
I have noticed that this version is in the /bin/ folder, which may be the problem? Since the other version installs in the /local/ folder.
How do I remove the old git version 1.9.0 so I can successfully install the new version? (without affecting any of the applications I'm working on)
Thanks for having a look and for any input!

The Git in /usr/local (presumably 1.9.0) is shadowing the new release. To determine which program to use, your shell looks through a list of directories stored in your PATH environment variable. You can see it with echo $PATH. Generally /usr/local/bin comes before /usr/bin so you can use newer versions of software without overwriting the system supplied ones.
You need to remove the old version from /usr/local. How you do this depends on where you got Git 1.9.0. If it has an uninstaller, use it. If it doesn't, you can look through /usr/local and delete anything with "git" in it, that will probably be safe.
In the future, use a package manager like Homebrew or Macports. They will track what you have installed and make it much easier to upgrade them.

Related

Why do I have two versions of sqlite?

On my iMac (10.13.6, which is as far as it can be upgraded), I typed sqlite3 and it said I was running version 3.19.3.
So I tried upgrading with brew upgrade sqlite3 but it said sqlite3 3.28.0 already installed. The SQLite site says 3.28.0 is currently the most up to date version.
How come I have two different versions of SQLite? Does Brew install to a different location than the standard OSX version? And if so, how do I either use the upgraded brew version or upgrade the OSX version?
In general, homebrew installs links for all binaries it installs in /usr/local/bin. You can see that by running:
ls -l /usr/local/bin
So, you need to add that directory to your PATH:
export PATH=/usr/local/bin:$PATH
You likely want to do this in your login profile, which is probably $HOME/.profile so that it gets set every time you login.
I ended up creating alias command in the .zshrc file like so:
alias sqlite=/usr/local/opt/sqlite/bin/sqlite3
Don't know if that was the best way, though.

Installed git 1.8.4.2 on Mac, but git --version reports 1.8.3.4

I downloaded the latest version of git - 1.8.4.2 - from git-scm.com/download/mac
After I installed it, if I enter git --version in a terminal window, the version is reported as 1.8.3.4.
I ran the uninstall script for both version, but git continues to report 1.8.3.4 on my system.
I'd like to:
Delete git entirely from my system and
install the latest version from the URL above.
Can someone let me know the best way to do this?
Rather than removing system binaries (why would you want to do that?) you should do one of two things:
Check your $PATH and ensure that things you install have a higher position in the $PATH than the system defaults,
Move /usr/bin/git to /usr/bin/git-1.8.3.4, then symlink the one from /usr/local/bin to /usr/bin/git.
Both of these will allow you to keep both versions in such a way you can choose which to run (providing full path, for example), while also making the most recent install the default.
As an aside, if you've installed from source yourself, I'd recommend building the binary with the version number either in the path or in the binary name (/usr/local/git/1.8.4.2/bin). If you're aiming to keep git up-to-date, this will probably save you some hassle down the track when you're installing for the nth time.
If you're on a mac, check out homebrew, too - the latest git is 1.8.4.3, so it appears up-to-date.

How to install older version(1.6.18) svn on MAC

The MAC provide the #1.7.10 SVN client, but my project is using #1.6.18 SVN.
So that I received the error message "Working copy is too old (format 10, created by Subversion 1.6)"
Current I CANNOT upgrade my project svn version. So I think the only way for me is re-install the older version SVN. (please kindly advise me if there is better solution)
And my questions are:
Can I use the #1.7 SVN client on #1.6 SVN working copy? IF NO
How can I uninstall older SVN and re-install older version SVN?
Thanks for your help.
There's no problem using version 1.7.10 even if your server is 1.6.8. What you shouldn't do is share working copies between systems. There is no guarantee that one Subversion client will use the same working copy format as another. For example, some Windows clients use _svn directories instead of .svn directories -- especially for VisualStudio development.
For the longest time, most clients used the default Subversion client format that has pretty much remained unchanged until the 1.7 client. In that client, the .svn folders found in each directory were removed to have just a single .svn folder in the root of the directory. This makes the 1.7 command line client working copy incompatible with the earlier formats.
You never explained how your Mac has a 1.6.8 working copy on it. Is it that you have some sort of GUI client on your Mac that is using the older format, or do you have a share that you use on two different systems. If you're doing the latter, don't. Check out a separate working copy on each system.
If you need to share changes between working copy without doing a commit, use the svn diff command to create a patch file. Then use svn patch to apply this patch file to the other working copy.
A 1.7 client can work on a 1.6 WC after you execute svn upgrade. After that event, 1.6 clients will not be able to use that working copy.
You can install another version of SVN to a non-default path, and either put that path earlier in your $PATH environment variable, or specify the full path to the binary each time you use it (if you go this route, you can create an alias in your shell to simplify it, but be careful as you might get confused as to which svn is which)
Install the older version in a location on your path that is either higher than the default implementation.
i.e. svn is installed in /usr/bin/ by default (as I can see on my system) but usr/local/bin is higher in my PATH, so if I were to do this I would install the older version in usr/local/bin
There is another way. You can rollback from 1.7 (should work on Mavericks) to 1.6.
Save your existing 1.7 install to another folder
sudo mv /usr/bin/svn* ~/Documents/svn_1.7
Install XCode and symlink the 1.6 version from there
/Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svn /usr/bin/svn
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svnadmin /usr/bin/svnadmin
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svndumpfilter /usr/bin/svndumpfilter
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svnlook /usr/bin/svnlook
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svnserve /usr/bin/svnserve
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svnsync /usr/bin/svnsync
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/subversion-1.6/bin/svnversion /usr/bin/svnversion
Voila!

How to update my version of git on OSX 10.8

I'm on OSX 10.8.2 and I'm running git git v1.7.4.4
I just installed git on a remote server and it's version 1.11.x. I'm I would like to be running the same version of the software but I cannot figure out how to update git on my laptop.
I attempted to follow the steps listed here, which instruct to download the git-OSX-installer, run the install (which ran smoothly) and then do:
$ sudo mkdir -p /usr/local/bin
$ sudo ln -s /usr/local/git/bin/git /usr/local/bin/git
But after this I do git --version and it's still 1.7.4.4. Did I just reinstall the same version? Or did I install a newer version somewhere else?
I've been reading similar questions and I think the issue is that OSX ships with an old version of git installed in a different location then where the git-osx-installer or mac ports will put it. But I'm not sure how to correct this. Thanks in advance for your advice.
Update:
which git returns:
/usr/bin/git
echo $PATH returns:
/opt/local/bin:/opt/local/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin
Update2:
ESL ~/Downloads$ export PATH=/usr/local/bin:$PATH
ESL ~/Downloads$ which git
/usr/local/bin/git
ESL ~/Downloads$
ESL ~/Downloads$ git --version
git version 1.8.1.3
It appears I installed the newer git version in local. So should I add the export PATH=/usr/local/bin:$PATH to my .bash_profile? Is it a problem that both versions of git are installed?
I added export PATH=/usr/local/bin:$PATH to the bottom of my ~/.bash_profile and now the new version of git runs.
The best way to update any binary on a Mac OSX machine is to use the package(s) developed specifically for Mac (a .dmg or .pkg download).
In the case of git this is at: http://git-scm.com/download/mac
(clicking on this link should automatically start the download of the latest version of git for Mac).
However, in this case (at least for my 10.8.3 MacBook) this was not quite the whole story: the package installs git in /usr/local/git and then adds that path at the end of $PATH - which defeats the whole purpose IMO.
I have manually modified my .bashrc so as to have something similar to what suggested above:
export PATH=/usr/local/git/bin:$PATH
Once you do that, you should see the correct version of git being picked:
$ git --version
git version 1.8.2.2
Note that this won't work for any app that is launched interactively (eg, via the docking bar) - you'll have to run the additional script provided in the downloaded package; see the README for instructions.
Since /usr/bin shows up before /usr/local/bin in your path, the git executable in /usr/bin will be given precedence.
try this in your shell:
export PATH=/usr/local/bin:$PATH
which git
On a side note, I'd strongly recommend using homebrew for managing installations such as this on macos
I had a similar issue in Cygwin (linux environment compiled for windows). I would do
which git
and it would respond with the correct location of the updated git compiled from source, but wouldn't actually use it until I did
hash -r git
I don't claim to understand what this did or why it had to be done, but after that git --version replied with '1.8.2.rc0.22.gb3600c3' which was clearly no longer the old git shipped with Cygwin. This may not apply to OSX, but give it a shot if which git is locating the updated binary.

override git from Xcode with homebrew version

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.
But the homebrew version of git is never called since my PATH looks like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which means the /usr/bin/git is allways called before /usr/local/bin/git.
Is there a way to change that without changing the PATH?
Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:
Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).
Since Xcode hard coded its own version of git which is installed on /Applications/Xcode.app/Contents/Developer/usr/bin/git, I managed to use this work around trick:
change into the Xcode directory:
cd /Applications/Xcode.app/Contents/Developer/usr/bin
rename the Xcode's git like this:
sudo mv ./git ./git-xcode-usr-bin
link my own git which is installed through homebrew:
sudo ln -s /usr/local/bin/git ./git
And I did the same thing with /usr/bin/git
This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)
Certainly this may cause some other problems, such as when I upgrade the homebrew's verion git in the future, it would not work for me :( and I have to make a new link then.
I do it like this because I want to solve my own problem here 13177203. And after search StackOverFlow for a long time, I finally got this solution.
If you are using fish shell instead of bash, you can point to your preferred git binary by adding the following to ~/.config/fish/config.fish.
function git
/usr/local/bin/git $argv;
end

Resources