TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Bad Habits of a New Git User

2 pointsby philk10almost 3 years ago

1 comment

simonblackalmost 3 years ago
<i>Branches</i> <i>The Bad Habit: “Oops was I on main for that?”</i><p>I found somewhere on the Net one day a few years back, a small bash addition that includes the git branch on the command-line prompt if the directory happens to be part of a git repository. Thus:<p><pre><code> centrepoint [jvs] &#x2F;home&#x2F;jvs&#x2F;wrk&#x2F;njvtax [master*] &gt; ^ ^ ^ [this part is the commandline prompt] &lt; git &gt; [final part] [ with HOSTNAME, USERNAME, CWD ] &lt;branch&gt; [ of prompt] </code></pre> The git branch is colored red (or your favorite color). The rest of my prompt is black-on-white, so the git branch really stands out to me. Directories that aren&#x27;t in a git repository will obviously never show any git branch-name, as in:<p><pre><code> centrepoint [jvs] &#x2F;home&#x2F;jvs&#x2F;hhnse &gt;</code></pre>