Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button

A Waage Blog

Ruby, Rails, Life

Archive for the ‘branch’ tag

Git – Push a branch to remote repository

without comments

So you just created a new branch locally. You put in 200 hours into this branch, and then realize that the only copy of all these changes is on your MacBook! Don’t get scared, just push the branch to your remote server.

It’s easy:

$> git push -u <remote-name> <branch-name>

Or, usually:

$> git push -u origin branch-name

Written by Andrew Waage

August 26th, 2011 at 1:23 pm

Posted in Git and SVN

Tagged with , , ,

Add colored git branch name to your shell prompt

with 2 comments

Here’s a little trick to get the name of your current git branch in your shell prompt. No more figuring out that you have made changes to the wrong branch once it’s too late! Your shell will not change for normal (non-git) folders. But, once you change directory into a git project, you will see the branch name added to your shell prompt like such:

Macintosh-2:git_project_foo andyuser [master] $

Simply add the following to your ~/.bash_profile or ~/.bashrc file:

function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
PS1="\h:\W \u\[\033[0;32m\]\$(parse_git_branch_and_add_brackets) \[\033[0m\]\$ "

That’s all there is to it ! Try it out !

Written by Andrew Waage

October 19th, 2009 at 3:10 pm

Posted in Git and SVN

Tagged with , , ,