<div dir="ltr"><div><div>Hi Giles,<br><br></div>Try installing 'gitk' graphical tool that visualize a lot of things your asking about. Just run "gitk &" from anywhere under your git project root repository.<br><br></div>Alex.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 6, 2015 at 10:29 AM, Giles Orr <span dir="ltr"><<a href="mailto:gilesorr@gmail.com" target="_blank">gilesorr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've started using git fairly heavily (although not necessarily very<br>
well).  I have several repos: a couple are code, also my ~/.vim/<br>
folder and I'm thinking about adding ~/bin/ .  If I remember to push<br>
from a particular machine before leaving it, I'll never have to deal<br>
with merging as I'm the only user.  While most likely my discomfort<br>
with merging will be overcome by practice as I understand git does it<br>
well (I use SVN at work: merging is shudder-inducing), I'm guessing<br>
keeping everything up to date is still preferable.  These questions<br>
are mostly about incorporating information about the repo into the<br>
Bash prompt: I was impressed recently by the way zsh appears to handle<br>
it, with a sequence of tiny icons in the lower right corner of the<br>
terminal indicating relative status.  I didn't talk to the zsh user<br>
long, so I don't know if that's built-in, a plugin, or something he<br>
did himself.<br>
<br>
I'm starting from some code I got from <a href="http://nitrous.io" target="_blank">nitrous.io</a>, lovely in its conciseness:<br>
<br>
parse_git_branch () {<br>
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/*<br>
\(.*\)/\1$(parse_git_dirty)/"<br>
}<br>
parse_git_dirty () {<br>
  git diff --no-ext-diff --quiet --exit-code &>/dev/null || echo "!"<br>
}<br>
<br>
Put \$(parse_git_branch) into your prompt and it tells you what branch<br>
you're on, and if there are any unstaged changes (and goes away if<br>
you're not in a repo).  I'd prefer it did uncommitted rather than<br>
unstaged, haven't tried to fix that yet.  But I want to update it as<br>
it doesn't deal with origin at all.<br>
<br>
So, the questions:<br>
<br>
What is the easiest and most concise way to determine if your local is<br>
behind origin master?  I've found that "git remote show origin" will<br>
show this information, but I'm not sure if it's the "best" way to find<br>
out, and I'm also concerned that running that every time your prompt<br>
comes up would slow things down as it makes a remote call(?) to get an<br>
answer - when you might not even have a network connection, or worse,<br>
a very slow connection.<br>
<br>
"git status" usually says "Your branch is up-to-date with<br>
'origin/master'" (or "ahead"), but occasionally - even though origin<br>
is configured properly - this line doesn't appear.  Is there a way to<br>
convince it to always show this line?<br>
<br>
Unfortunately, "git status" doesn't seem to ever notice if you're<br>
"behind" origin, thus the need for "git remote show origin".  Any fix<br>
for that?<br>
<br>
The thought was to have output for the prompt that looked like this:<br>
<br>
(everything synced): "master-"<br>
(uncommitted local changes): "master!-"<br>
(behind origin): "master^"<br>
(ahead of origin): "masterv"<br>
(ahead and behind, with local changes): "master!^v"<br>
<br>
You get the general idea.<br>
<br>
I'm aware git is capable of immense complexity (branches, detached<br>
head, multiple remotes, different remotes for push and pull, etc.)<br>
that aren't addressed here.  If I tried to tackle all of that at once<br>
(especially given I don't understand most of it) my head would explode<br>
and nothing would get done.  So I'm sticking with my simple use case<br>
until I have to deal with the more complex stuff.<br>
<br>
Any thoughts welcome.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Giles<br>
<a href="http://www.gilesorr.com/" target="_blank">http://www.gilesorr.com/</a><br>
<a href="mailto:gilesorr@gmail.com">gilesorr@gmail.com</a><br>
---<br>
Talk Mailing List<br>
<a href="mailto:talk@gtalug.org">talk@gtalug.org</a><br>
<a href="http://gtalug.org/mailman/listinfo/talk" target="_blank">http://gtalug.org/mailman/listinfo/talk</a><br>
</font></span></blockquote></div><br></div>