Browse files

Add `github fetch <user> <branch>` command.

This will create a remote for <user>, fetch the branch into refs/remotes/<user>/<branch> and then create a local branch from that. This is good for getting an exact copy of the branch (without merging it into another branch) for local testing or inspection.
  • Loading branch information...
1 parent fe1f852 commit dc053418ebce19d0b2d87bf25f87990dafb09e99 @mojombo committed Sep 30, 2008
Showing with 11 additions and 0 deletions.
  1. +11 −0 commands/commands.rb
View
11 commands/commands.rb
@@ -61,6 +61,17 @@
end
end
+desc "Fetch from a remote to a local branch."
+command :fetch do |user, branch|
+ die "Specify a user to pull from" if user.nil?
+ user, branch = user.split("/", 2) if branch.nil?
+ branch ||= 'master'
+ GitHub.invoke(:track, user) unless helper.tracking?(user)
+
+ git "fetch #{user} #{branch}:refs/remotes/#{user}/#{branch}"
+ git_exec "checkout -b #{user}/#{branch} refs/remotes/#{user}/#{branch}"
+end
+
desc "Pull from a remote."
flags :merge => "Automatically merge remote's changes into your master."
command :pull do |user, branch|

0 comments on commit dc05341

Please sign in to comment.