Categories
coding tips

Change author of last commit in git

If you use multiple emails in your repos (ex. work and private) you may have encountered a situation where your commit was rejected from the remote repository, due to bad email used. In order to fix that all you need to do is to set the correct e-mail for current repository:

git config user.email "your_correct@email.com"

and then, reset the author of the last commit:

git commit --amend --reset-author --no-edit

This command can also be used with git rebase -i on edited commits.

Categories
coding tips Uncategorized

neovim as git difftool (mergetool)

I moved completely to neovim. It’s my default editor, to the point that I don’t bother installing new plugins for vim. And that’s how I realised that git difftool is still using vim.

I recently installed a new colorscheme using Plugged, and launching git difftool would give me errors, because I didn’t install it for vim. The solution turned out to be simple. Git’s mergetool has the option to configure path for the desired tool. So I’ve set up mergetool to use vimdiff (diftool will use the same tool by default).

git config --global merge.tool vimdiff
git config --global mergetool.vimdiff.path nvim
Categories
coding tips

Ignore files in git without editing .gitignore

You work on a repository where the .gitignore file is defined globally and already tracked by git, but you have some files in your local directory that you don’t want to be tracked (logs, or build files, *.pyc etc.) and would like to ignore them (because who doesn’t like git status to show “working tree clean” or the status bar in zsh to be green).