Share git configuration in repo

Today I learned that you can share a git config file in a repository for easily sharing certain local config settings with your team. git config --local include.path ../.gitconfig This adds the following to your local config [include] path = ../.gitconfig and will load any config values set in that file. This has a couple advantages in that we only have to run a single git command and if we need to make future changes we only have to update the config file instead of requiring devs to run additional commands to get the update. ...

Working with stacked branches in git (Part 2)

Working with stacked branches in git (Part 2) Andrew as always has a very handy and thorough post on some advanced git techniques. I’m also a fan of stacked branches but it’s definitely tricky to get the flow right without some extra tooling help.

Use skip-worktree to ignore modified files

Today I learned about the --skip-worktree command in git which will treat a file like it hasn’t been modified. This is useful if you have to modify a file locally but don’t ever want to commit it (config files are a common scenario). Like me, you may have seen --assume-unchanged used in this way but that’s not what it’s meant for since it’s “designed for cases where it is expensive to check whether a group of files have been modified”. As a result you’re likely to lose the changes you have made to those files. This post shows a good summary of the outcomes of common operations with each command. ...

How I configure my Git identities

How I configure my Git identities | benji This is pretty cool and I’m immediately implementing it!

Verifying tricky git rebases with git range-diff

Verifying tricky git rebases with git range-diff Git’s range-diff command is pretty powerful but I feel like it’s not talked about enough and it could definitely use a nicer UI so I’m Andrew is helping to demystify it.

How to Write Useful Commit Messages

How to Write Useful Commit Messages I’ve long been a fan of writing more detailed commit messages and this is an excellent write-up on how to do that.

Git Stash Without the Branch Name

I found a way to stash changes in git without including the branch name in the stash message. This might be a very niche use case but it’s been a minor annoyance for me for some time. If you just want the alias, then add the following to your .gitconfig: [alias] sm = "!f() { git stash || exit 1; rev=$(git rev-parse stash@{0}) && git stash drop stash@{0} || exit 1; git stash store -m \"$1\" $rev; }; f" You can also use this technique for renaming stashes. ...

Stash changes in the index

I just recently discovered that Git 2.35 added the --staged option to the git stash command. This makes it easy to quickly stash only the changes that you’ve staged.

Selectively restoring changes from another branch or commit

Today I learned that you can use the --patch parameter with several git commands. The --patch parameter is probably most known for interactively staging changes from the cli, but I’ve never really used it because I find GUI clients are much more convenient for this. But apparently you can also use it with restore/checkout to grab specific changes from another branch. git restore --source=branch-name --patch This is something I haven’t seen easily done in any git client. ...

Personal git ignore per repository

Today I learned that git has a $GIT_DIR/info/exclude file can contain additional patterns of files to ignore but isn’t committed to the repository. For me this is handy for some tooling configuration files that I use personally but don’t want to clutter the main .gitignore of the repo. If there are some files that you want to always ignore, then you can specify a global ignore file in your git config with core.excludesFile. ...