08 July 2010 ~ 0 Comments

How to reset/revert a single file with git

I’m making this post more for my own reference than to help anyone else, but feel free to comment if you have questions or anything.

If you’ve made a commit with git (let’s call it “commit A”), and you want to make another commit (let’s call it “commit B”) that, among other things, reverts the changes made to a single file (let’s call it file1.rb) in commit A, use the following command:

git reset commit-a -- path/to/file1.rb

That’ll create two sets of changes: a copy of the changes you made in commit A, and the inverse of the changes you made in commit A. The inverse is staged, while the copy is unstaged. Nine times out of ten, you’ll want to commit the staged changes (which, as they’re the inverse of the changes in commit A, will result in a revert of file1) and discard the unstaged ones.

Continue Reading

13 January 2010 ~ 5 Comments

Installing Ruby on Rails 2.3+ plugins from github

I’ve been banging my head against this wall for quite awhile now, and I just finally figured out the answer. Like I’ve done in other posts, I’ll just post what worked for me, and hopefully it’ll help other people.

I’m running Ruby 1.9 and Ruby on Rails 2.3.3 on Snow Leopard. I’ve been trying to install plugins (specifically, Authlogic and Carmen) for a couple days now using the following two commands (as taken from the main github pages):

script/plugin install git://github.com/binarylogic/authlogic.git
script/plugin install git://github.com/jim/carmen.git

In return, I received the following errors:

Plugin not found: ["git://github.com/binarylogic/authlogic.git"]
Plugin not found: ["git://github.com/jim/carmen.git"]

After a lot of poking around, it turns out you need to make two changes in order for this to work on Rails 2.3 or higher: change the git:// at the beginning of each URL to http://, and add a trailing slash to the end of each URL. So instead, run these:

script/plugin install http://github.com/binarylogic/authlogic.git/
script/plugin install http://github.com/jim/carmen.git/

They both worked perfectly for me, so hopefully they’ll work for you. If not, leave a comment and I’ll try to help.

Continue Reading