Code Monkey home page Code Monkey logo

git_remote_branch's Introduction

Archived

This repository is not maintained and this tool is no longer really necessary. It has therefore been archived.

Why not git_remote_branch?

Because this gem is barely being maintained anymore. Also, the code is so old that I want to cry every time I look at it :-(

But it still works, I guess…

Why git_remote_branch?

git_remote_branch is a simple command-line tool that makes it very easy to manipulate branches published in shared repositories.

It achieves this goal by sticking to a few principles:

  • keep grb’s commands extremely regular (they all look alike)

  • support aliases for commands

  • print all commands it runs on your behalf in red, so you eventually learn them

Another nice thing about git_remote_branch is that it can simply explain a command (print out all the corresponding git commands) instead of running them on your behalf.

Note: git_remote_branch assumes that the local and remote branches have the same name. Multiple remote repositories (or origins) are supported.

Installation

gem install git_remote_branch

If you use RVM, you may want to automatically install it on all rubies you’ll install in the future:

echo git_remote_branch >> ~/.rvm/gemsets/global.gems

If you’re on Windows, you can optionally install the following gems, to get color output:

gem install windows-pr win32console

Auto-completion

If you use zsh with oh-my-zsh, you can have grb auto-completion by using the git-remote-branch plugin.

# ~/.zshrc
plugins=(git git-remote-branch ...)

If you use bash, you can have grb auto-completion by souring ‘etc/grb-completion.bash`

# ~/.bash_profile (after your Ruby has been set, e.g. after the RVM snippet)

grbc=`gem contents git_remote_branch | grep grb-completion.bash` && source $grbc

or copy it to your desired destination and source it.

Usage

Notes:

  • parts between brackets are optional

  • When ‘origin_server’ is not specified, the name ‘origin’ is assumed.

Available commands (with aliases):

Help

$ grb [-h|help]    #=> Displays help

create (alias: new)

Create a new local branch as well as a corresponding remote branch based on the branch you currently have checked out. Track the new remote branch. Checkout the new branch.

$ grb create branch_name [origin_server]

publish (aliases: remotize, share)

Publish an existing local branch to the remote server. Set up the local branch to track the new remote branch.

$ grb publish branch_name [origin_server]

delete (aliases: destroy, kill, remove, rm)

Delete the remote branch then delete the local branch. The local branch is not deleted if there are pending changes.

$ grb delete branch_name [origin_server]

track (aliases: follow grab fetch)

Track an existing remote branch locally and checkout the branch.

$ grb track branch_name [origin_server]

rename (aliases: rn mv move)

Rename a remote branch and its local tracking branch. The branch you want to rename must be checked out.

# On branch to be renamed
$ grb rename new_branch_name [origin_server]

explain

All commands can be prepended by the word ‘explain’. Instead of executing the command, git_remote_branch will simply output the list of commands you need to run to accomplish that goal. Examples:

$ grb explain create
git_remote_branch version 0.3.8

List of operations to do to create a new remote branch and track it locally:

git push origin master:refs/heads/branch_to_create
git fetch origin
git branch --track branch_to_create origin/branch_to_create
git checkout branch_to_create

Explain your specific case:

$ grb explain create my_branch github
git_remote_branch version 0.3.8

List of operations to do to create a new remote branch and track it locally:

git push github master:refs/heads/my_branch
git fetch github
git branch --track my_branch github/my_branch
git checkout my_branch

This, of course, works for each of the grb commands.

More on git_remote_branch

History

git_remote_branch in its current form was inspired by a script created by Carl Mercier and made public on his blog: No nonsense GIT, part 1: git-remote-branch

Contributors

Legalese

git_remote_branch is licensed under the MIT License. See the file LICENSE for details.

Supported platforms

This version of git_remote_branch has been tested with

  • OS X Mountain Lion

  • past versions were known to work on Linux and Windows

  • Ruby 1.9.3

  • git 1.7+

Let me know if you encounter problems running git_remote_branch with your platform.

git_remote_branch's People

Contributors

axelson avatar hsatac avatar kch avatar lbrapid avatar rossmeissl avatar sumbach avatar toy avatar webmat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git_remote_branch's Issues

Need --force/-f flag for grb delete

It would be nice to be able to grb delete -f branch_name and have it run git branch -D branch_name to remove it even if it isn't fully merged.

Deprecation of --set-upstream flag in git >=1.8.0

When using grb publish with git >=1.8, I get the following warning message:

git branch --set-upstream my-branch origin/my-branch
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

grb not working under ruby 2.1.0? "undefined method `foreground'"

Hi Webmat,

I tried to install grb under ruby 2.1.0. upon usage, I have the following error:

$> ruby --version     
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]

$> grb publish feature/compas14 

git_remote_branch version 0.3.7
/Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:145:in `block in puts_cmd': undefined method `foreground' for "git push origin feature/compas14:refs/heads/feature/compas14":String (NoMethodError)
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:144:in `each'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:144:in `puts_cmd'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:137:in `block in execute_cmds'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:136:in `each'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:136:in `execute_cmds'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/lib/git_remote_branch.rb:123:in `execute_action'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/gems/git_remote_branch-0.3.7/bin/grb:39:in `'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/bin/grb:23:in `load'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/bin/grb:23:in `'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/svarrette/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `'

It works fine under ruby 1.9.3

Odd remove branch syntax...

Apparently this is supposed to be something like git push origin :pforhan/attach-id instead. Or is this just a misbehaving pre-receive hook?

[pforhan ~/dev/ (master $=)]$ grb remove pforhan/attach-id
git_remote_branch version 0.3.8

git push origin :refs/heads/pforhan/attach-id
remote: Hook net.nullsinn.stash.hooks.forcepush.ProtectRefHook failed. Error: 
remote: The syntax used for the command is incorrect.
To ssh://[email protected]/android/project.git
 ! [remote rejected] pforhan/attach-id (pre-receive hook declined)

Git 1.7 compatibility for publish

grb publish doesn't work on git 1.7.x.

For git 1.8.x the command for setting the upstream branch of a local branch is:
'"#{GIT} branch -u #{origin}/#{branch_name} #{branch_name}"',

But for git 1.7.x, the command is:
'"#{GIT} branch --set-upstream #{branch_name} #{origin}/#{branch_name}"',

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.