-
-
Save Abizern/774277 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python -tt | |
"""Xcode4 installs and expects to find a git installation at /usr/bin. | |
This is a pain if you want to control your own installation of git that | |
might be installed elsewhere. This script replaces the git files in | |
/usr/bin with symlinks to the preferred installation. | |
Update the 'src_directory' to the location of your preferred git installation. | |
""" | |
import sys | |
import os | |
#- Configuration ----------------------------------------------------------------- | |
src_directory = '/usr/local/git/bin/' # preferred installation | |
#---------------------------------------------------------------------------------- | |
dest_directory = '/usr/bin/' | |
files = ('git','git-cvsserver','git-receive-pack','git-shell','git-upload-archive','git-upload-pack','gitk') | |
def main(): | |
if os.getuid(): | |
print "This script needs to be run as 'sudo python update_git.py'" | |
sys.exit(1) | |
for a_file in files: | |
src_file = os.path.join(src_directory, a_file) | |
dest_file = os.path.join(dest_directory, a_file) | |
if os.path.exists(dest_file): | |
os.remove(dest_file) | |
os.symlink(src_file, dest_file) | |
if __name__ == '__main__': | |
main() |
Applied some suggestions.
Script requires sudo to run and uses the OS module to create the symlinks.
Just a small note : caius' script does the contrary of the python script.
If you want to update git and use it as default, FROM_DIR and TO_DIR should be exchanged in the zsh script.
Thanks, maybe one day xcode will update their git..
The version of Git that comes with Xcode is fairly recent. This script is just for those who want to use the development builds of Git.
Can any one help me. I am setting up my local development environment. I have a server (MAC OS X Lion Server) and want that to house git and use the repository over http. I followed all the steps from http://www.pkgbox.org/wordpress/2011/08/setting-up-a-git-server-on-macos-x-lion/ but now I get fatal: http:/myname@server/repo/test-project.git/info/refs not found did you run git update-server-info on the server? Please help i am running out on time... I want to use git and start this project...
What caius said: don't do sudo inside the script, require that it gets called with sudo. Also, consider a "and your original files have been moved to ${SAFEPLACE}" option :-D