Skip to content

Commit

Permalink
Add github fetch <user> <branch> command.
Browse files Browse the repository at this point in the history
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
mojombo committed Sep 30, 2008
1 parent fe1f852 commit dc05341
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions commands/commands.rb
Expand Up @@ -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|
Expand Down

0 comments on commit dc05341

Please sign in to comment.