15 Tips to Enhance your Github Flow

15 Tips to Enhance your Github Flow” has lots and lots of good advice for anyone working with GitHub.  Tips vary from PR templates all the way to automated dependency management and updates.  Really useful!

git worktree – a better way for git stash abusers

If you constantly find yourself using “git stash” while working on a project, or, even worse – have multiple copies of the same project cloned on the same machine, “git worktree” might be a much better alternative for you.

Manage multiple working trees attached to the same repository.

A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With git worktree add a new working tree is associated with the repository. This new working tree is called a “linked working tree” as opposed to the “main working tree” prepared by “git init” or “git clone”. A repository has one main working tree (if it’s not a bare repository) and zero or more linked working trees.

When you are done with a linked working tree you can simply delete it.

Here are a few links to get you started:

 

commandlinefu – a place to share and gather command line wisdom

commandlinefu is a place to learn and share your knowledge about command line tools and techniques.  It has thousands of tips, tricks, and handy shortcuts, covering a wide range of tools from shells and editors to version control and remote access.

Gitea – self-hosted Git service

Gitea is yet another alternative to BitBucket, GitHub, and GitLab Cloud.  It’s an open source solution for self-hosting Git repositories.  It’s a fork of Gogs, written in Go, and is available under the MIT license.

git clean – a nice addition to git reset

Anybody working with git is probably well familiar with the way to undo the non-committed changes:

git reset --hard

As useful as the above command is, it still leaves some room for improvement. The above command will only undo non-committed changes on the files that git is tracking. Often, this would leave a whole bunch of files and directories in place, which are not tracked by git. So far, I’ve been using a really complicated approach for removing them, which involves git status, grep, cut, xargs, and rm. Yuck.

Turns out there is a better way, which I found in “Stupid git tricks” article:

git clean -df .

This one will forcefully remove all untracked files and directories from the current directory. Combining these two commands together results in all non-committed changes being undone, no matter if they are on tracked files or not. Cool!