git branch help?
Karel Zak
kzak at redhat.com
Tue Aug 3 09:44:02 UTC 2010
On Tue, Aug 03, 2010 at 12:56:37PM +0530, Rahul Sundaram wrote:
> On 08/03/2010 12:53 PM, Peter Hutterer wrote:
> > correct, git will share objects between branches, so by storing in different
> > directories you'll loose that advantage.
> >
> > I've got a shell prompt that shows me the branch name whenever I enter a git
> > directory so I don't have to worry about committing to the wrong branch.
>
> For those wondering how,
>
> http://blog.vagmim.com/2009/04/git-branch-on-command-prompt.html
This is pretty primitive implementation (do you really want to call
python from $PS1? ;-)
The git package contains the /etc/bash_completion.d/git file where
is defined function __git_ps1() which provides more usable strings
(it's able to detect if you are rebasing, bisecting, merging, ...) and
allows to use formatting for the string:
$ echo $(__git_ps1 "git PS1 is: %s")
git PS1 is: master
For example I use
PS1='\h:\w\[\033[0;32m\]\$\[\033[0m\] '
PROMPT_COMMAND='printf "%*s\r" "$(($COLUMNS + 11))" "^[[33m$(__git_ps1 ":%s")^[(B^[[m"'
so I have "hostname:dirname$" on left side and ":branch" on right (the
branch name is yellow and '$' at the end of dirname is green:-)
Karel
--
Karel Zak <kzak at redhat.com>
http://karelzak.blogspot.com
More information about the devel
mailing list