Ever used SVN or SVK? Git is another source code management (scm) system that has been getting a fair bit of attention of late. I recommend giving it a try if you haven’t done so already.
Unfortunately it can live up to it’s name when it comes to installing on an Intel based Mac. More so if you recently migrated from a PPC Powerbook and hadn’t updated your Darwin ports. All your libraries are likely to be compiled for the wrong architecture leaving you with messages like this:
/usr/bin/ld: warning /opt/local/lib/libz.dylib cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (file not loaded)
The long and the short of it is that you will need to re-install darwin ports from scratch and then do a manual install.
Here are the steps you take:
Make sure you have the latest version of XCode: http://developer.apple.com/tools/download/
Remove ports (this will be the case if you have installed ImageMagick or similar in the past) See http://www.nabble.com/I’ve-hosed-my-ports-install,-clean-slate-install—t3868686.html
Always backup before you do these kind of things, esp if you depend on anything in your ports install
Reinstall Darwin ports: http://darwinports.com/download/
Install git through ports (this only gets you the 1.4.2 version though)
sudo port install git-core
At this point you could just stop but if you want the latest and more advanced features its worth
carrying out a manual install. Especially if you want to transfer files from an existing SVN repo.
Install git manually (now you have dependencies from the dawinports install)
cd /usr/local/src curl http://kernel.org/pub/software/scm/git/git-220.127.116.11.tar.gz > git-18.104.22.168.tar.gz tar -xvzf git-22.214.171.124.tar.gz cd git-126.96.36.199 make configure ./configure --prefix=/usr sudo make install
Test it out
The most commonly used git commands are:
martin$ git --version git version 188.8.131.52 martin$ git-svn --version git-svn version 1.5.2 (svn 1.4.3) martin$ git usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
add Add file contents to the changeset to be committed next apply Apply a patch on a git index file and a working tree archive Creates an archive of files from a named tree bisect Find the change that introduced a bug by binary search branch List, create, or delete branches checkout Checkout and switch to a branch cherry-pick Apply the change introduced by an existing commit clone Clones a repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink prune Prunes all unreachable objects from the object database pull Fetch from and merge with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state revert Revert an existing commit rm Remove files from the working tree and from the index show Show various types of objects show-branch Show branches and their commits status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG (use 'git help -a' to get a list of all installed git commands)
This is all bit a convoluted to be honest so if you have a better way then please feel free to chip in. Hopefully though if you end up in the same situation this might be the helping hand you were looking for.
Note: to get the docs to install you need to also install
sudo port install xmlto
sudo port install asciidoc
However I kept encountering time outs trying to pull libxslt (a dependency) from an external source so I moved on and skipped the docs for now.
If you want to use the git-svn command and end up with messages like this: “Can’t locate SVN/Core.pm in'. It might because you installed SVN from an installer. In which set the perl lib path to the parent directory of where SVN/Core.pm is located. In my case:
- http://git.or.cz/ – git homepage
- http://www.kernel.org/pub/software/scm/git/docs/tutorial.html – git tutorial
- http://utsl.gen.nz/talks/git-svn/intro.html – intro for those coming from SVN / SVK