How can I make git diff default to --color-words, instead of: [alias] wdiff = "diff --color-words"
$ git config color.diff always41–50 of 66 posts
How can I make git diff default to --color-words, instead of: [alias] wdiff = "diff --color-words"
$ git config color.diff alwaysI'm going through my gitconfig and I'm realizing there's ALL THESE really nice shortcut I literally never use.
[color "status"]
added = green
changed = yellow bold
untracked = red boldI have a ridiculous "vim style" alias setup: https://github.com/myfreeweb/dotfiles/blob/4eb052cc54f9edcc8... So I can just e.g. type "g ws" to tell [g]it to give me the [w]orking tree [s]tatus. Seeing people actually type "git status" is just painful.
Now you could decide to systematize the "grammar" of your shortcuts somehow, and, well... it's definitely an idea people have had before. ;)
https://magit.vc/screenshots/popup-diff.png
Not an Emacs fanboy, by any means: I use Spacemacs. Magit is objectively excellent, though.
# A nice shell prompt for inside git repostories
# Shows a short status of the repository in the prompt
# Adds an alias `g=git` and makes autocomplete work
gitprompt() {
__color_bold_blue='\[$(tput bold)\]\[$(tput setaf 4)\]'
__color_white='\[$(tput sgr0)\]'
export GIT_PS1_SHOWDIRTYSTATE=true;
export GIT_PS1_SHOWSTASHSTATE=true;
export GIT_PS1_SHOWUNTRACKEDFILES=true;
export GIT_PS1_SHOWUPSTREAM="auto";
export GIT_PS1_SHOWCOLORHINTS=true;
. /usr/lib/git-core/git-sh-prompt;
local ps1_start="$__color_bold_blue\w"
local ps1_end="$__color_bold_blue \\$ $__color_white"
local git_string=" (%s$__color_bold_blue)"
export PROMPT_COMMAND="__git_ps1 \"$ps1_start\" \"$ps1_end\" \"$git_string\""
# Short alias for git stuff
alias g=git
# Make autocomplete also work fo the `g` alias
eval $(complete -p git | sed 's/git$/g/g')
}
So I have this in my `.bashrc` and when I want my bash to get a handy Git prompt I type `gitprompt`.You do need the file `git-sh-prompt` which should come with git, for me it's located in `/usr/lib/git-core/git-sh-prompt`. It's also available here:
https://github.com/git/git/blob/master/contrib/completion/gi...
Which is not to dismiss these: Using magit involves its own cognitive load.
Oddly, the author recommends signing commits, yet uses only fast-forward merges. Little do they know that signed commits necessarily can not be resolved as fast-forwards in a merge situation, since that would require changing the signatures! Rebasing is the answer, but that will of course re-sign every commit with your key. In a shared repository, I prefer creating "useless" merge commits to changing other peoples si…
Is there some other part of a workflow that you're inferring here that will need changing commits?
As an alternative to git's aliases: if you're sick of typing `git' all the time, feel free to adapt this little script to suit your needs (allowing you to type e.g. `a' instead of `git add' and such, with tab completion):
https://gitlab.com/mikegerwitz/git-shortmapsWhen I want/need to customize this much, I tend to think poorly of the tool.
Most of the development tools I use on a regular basis tend to be extremely customizable, and I regard that as a Good Thing.