Git Icon

Git

Git is the most widely used version control system.
44 Stories
All Topics

Taylor Blau GitHub Blog

Git 2.28 brings `init.defaultBranch`

Leading off the updates for Git 2.28 is the highly sought after ability to configure init.defaultBranch so folks can move from master to main as their default branch name.

From Taylor Blau on the GitHub blog:

When you initialize a new Git repository from scratch with git init, Git has always created an initial first branch with the name master. In Git 2.28, a new configuration option, init.defaultBranch is being introduced to replace the hard-coded term. (For more background on this change, this statement from the Software Freedom Conservancy is an excellent place to look).

Starting in Git 2.28, git init will instead look to the value of init.defaultBranch when creating the first branch in a new repository. If that value is unset, init.defaultBranch defaults to master

Also check out github/renaming to learn more about the complementary changes GitHub is making. GitLab and Bitbucket are making similar changes.

Git 2.28 brings `init.defaultBranch`

Patrick DeVivo github.com

Using SQL to query git repos

gitqlite is a tool for running SQL queries on git repositories. It implements SQLite virtual tables and uses go-git. It’s meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

Mine your repo’s history for goodies. Here’s how to get commit count by author email:

SELECT author_email, count(*) FROM commits GROUP BY author_email ORDER BY count(*) DESC

Kabir Nazir altcampus.io

How to write good Git commit messages

From Kabir Nazir on the AltCampus blog:

One of the things a lot of newbie developers overlook often is the format of their commit messages. Properly formatted commit messages can do so much more than just looking neat…

Use the imperative mood(present tense) when framing messages … Think of each commit in your code as a change that is being applied to your codebase.

Patrick DeVivo github.com

Identify the most relevant git contributors based on commit recency, frequency, and impact

gitpert measures the “pertinence” of git authors as a time-decayed measure of LOC added and removed to a repository (or a set of files in a repository). It’s meant to help identify who the most relevant contributors are based on commit recency, frequency and impact.

Cool tool, as long as we don’t forget about non-code contributors.

The New Stack Icon The New Stack

How git changed the way we code

The New Stack takes us on a fun trip down memory lane:

Fifteen years ago a number of the Linux kernel developers tossed their hands in the air and gave up on their version control system, BitKeeper. Why? The man who held the copyright for BitKeeper, Larry McVoy, withdrew free use of his product on claims that one of the kernel devs had reverse engineered one of the BitKeeper protocols.

Linux creator Linus Torvalds sought out a replacement to house the Linux kernel code. After careful consideration, Torvalds realized none of the available options were efficient enough to meet his needs:

Drew Devault drewdevault.com

Drew Devault's unorthodox, branchless git workflow

In short, I use git branches very rarely, preferring to work on my local master branch almost every time. When I want to work on multiple tasks in the same repository (i.e. often), I just… work on all of them on master. I waste no time creating a new branch, or switching to another branch to change contexts; I just start writing code and committing changes, all directly on master, intermixing different workstreams freely. This reduces my startup time to zero, both for starting new tasks and revisiting old work.

If the blog post ended here, you might think Drew is crazy. But he goes on to explain how he uses rebase to clean things up before pushing upstream.

I enjoy hanging out on master quite a bit, myself. However, when I’m ready to take on something “big” or “gnarly” I don’t hesitate to git checkout -b and work from there.

Patrick DeVivo tickgit.com

Never forget a #TODO comment

Patrick DeVivo:

tickgit is a tool for software developers to do project management within their codebase. It searches code comments for markers indicating areas and files worth returning to (TODO, FIXME, etc). It can be used to proactively identify areas of technical debt, or handle day-to-day to-do items and checklists.

Free for public repos and open source.

Jonathan Carter github.com

GistPad for VS Code 📘

GistPad is a Visual Studio Code extension that allows you to manage GitHub Gists entirely within the editor. You can open, create, delete, fork, star and clone gists, and then seamlessly begin editing files as if they were local.

The big idea here is to use gists to seamlessly create your “very own developer library”. The interactive playgrounds is pretty cool, too.

GistPad for VS Code 📘

Victor Zhou victorzhou.com

Git aliases I use (because I'm lazy)

I’ve used Git for over a decade, but it doesn’t matter. Every single time I read a post like this one where somebody shares their aliases/shortcuts/etc, I pick up something new. Every. Single. Time.

What’s fun about this post is Victor also does the math to see if he’s actually saving himself time with all these aliases.

Assuming I type ~100 Git commands in an average 8-hour workday, that’s 550 characters saved, which converts to about one minute saved per day

That isn’t much time saved, but it still feels good, and that counts for something!

Jay Phelps github.com

git-blame-someone-else

This changes not only who authored the commit but the listed commiter as well. It also is something I wrote as a joke, so please don’t run this against your production repo and complain if this script deletes everything.

Alias this to git-take-the-credit so you can put your name on that awesome commit your co-worker made the other day. 😜

git-blame-someone-else

Git github.com

A tool to monitor Git repos and automatically pull & push changes

gitomatic <path>

2019/08/03 00:16:48 Checking repository: /tmp/gitomatic-test/
2019/08/03 00:16:48 Pulling changes...
2019/08/03 00:16:49 New file detected: hello_world.txt
2019/08/03 00:16:49 Adding file to work-tree: hello_world.txt
2019/08/03 00:16:49 Creating commit: Add hello_world.txt.
2019/08/03 00:16:49 Pushing changes...
2019/08/03 00:16:53 Sleeping until next check in 10s...
2019/08/03 00:17:03 Checking repository: /tmp/gitomatic-test/
2019/08/03 00:17:03 Pulling changes...
2019/08/03 00:17:07 Deleted file detected: hello_world.txt
2019/08/03 00:17:07 Removing file from work-tree: hello_world.txt
2019/08/03 00:17:07 Creating commit: Remove hello_world.txt.
2019/08/03 00:17:07 Pushing changes...
0:00 / 0:00