Git Error and File Rename

September 7th, 2011 by Eric Cope

We use Git here to manage all file versioning, mostly because its awesome. However, every once in a while we get an error message that is too cryptic, even for us. We recently got this message while trying to commit a file:

pathspec: 'filename' git did not match any file(s) known to git

It took some googling and some introspection, but we finally figured it out. We had deleted the file, Foursquarelib.php and replaced it with foursquarelib.php. Do you see the subtle difference? When we deleted Foursquarelib.php, we forgot to tell Git about the removal. Using the trusty command line, we:

touch Foursquarelib.php

Then, in our Git client, we “removed” Foursquarelib.php and added/commited foursquarelib.php, and Git was so excited for us, it couldn’t contain itself. All is well. We hope this helps somebody, maybe even ourselves in the future.

 

Automating Website Software Releases with Git

May 24th, 2011 by Eric Cope

We recently automated our release process for a new project we are working on, to be debuted shortly. We use Git as a version control system, but found keeping the website up to date to be too cumbersome. So, we scripted the whole release process on our server. Here is how we did it.

  1. We installed the Git client on the web server. Our incredible hosting company handled that for us with no issues.
  2. Next we generated some SSH keys for Git to use when we SSH to our Git server. These keys automate passwords, especially when we use ssh-agent to handle the key’s password.
    ssh-keygen -t rsa
  3. After transferring the public key to the Git server, we added that key, id_rsa, to ssh-agent
    ssh-add ~/.ssh/id_rsa

    This will prompt you for the key’s passphrase, not your SSH password.

  4. Copy the public key to the Git Server, obviously using scp or sftp. Add it to the ~/.ssh/authorized_keys file.
  5. Clone the Git repository
    git clone ssh://git.server.url:port/absolute/path/to/repository.git
  6. Script minutely|hourly|nightly|weekly resets and pulls from the Git server. I hard reset to restore the server to the pristine Git condition, then pull all updates from the Git server to make sure I’m as up to date as possible.
    git reset --hard
    git pull

Step 6 is completely scripted and I run as a cron job every night.  A side note regarding paths. My repository structure does not match the web server’s directory structures well. So, I added symbolic links to the necessary directories and I updated the permissions to allow the web server to run as intended.

How do you use Git to ensure proper release states of your website?

 

Installing a Git Server on FreeBSD, Using SmartGit

August 17th, 2010 by Eric Cope

We are in the process of migrating all new development to a git-based version control system. The main driver is the ability to check changes into a local database before the changes are fully tested and ready for the central server. Once the changes are ready, then we can push to the central server for everyone to use.
I basically used this link…

http://vanix.blogspot.com/2010/01/setup-git-server-on-freebsd.html

I’ve copy/pasted the important parts to ensure it doesn’t disappear.

install git server
$ cd /usr/port/devel/git
$ make install clean

modify /etc/rc.conf
git_daemon_enable=”YES”
git_daemon_directory=”/usr/local/git/repo”
git_daemon_flags=”–export-all –syslog –enable=receive-pack –listen=ip_address –verbose ”

add user – git
$ pw user add git
$ passwd git

start git daemon
$ /usr/local/etc/rc.d/git_daemon start

build local repository
$ mkdir /path/to/repo/mydroid.git
$ cd /path/to/repo/mydroid.git
$ git –bare init
$ chown -R git mydroid.git
$ chgrp -R git mydroid.git

I found through trial and error that that repository must be created on the server using the git –bare init command.

Once I had the server installed and running, I turned to configuring my gui client, Smart Git. I recommend both Smart Git and Smart SVN. They are terrific guis to assist in the adoption of version control systems. One hassle with Smart Git, was the undocumented requirement to use SSH keys for connecting to the server. The URL I used was an ssh url, but I thought it could do password authentication. Once I figured out to transfer my public key to the server’s user ssh directory, things connected nicely.