LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   setting git-diff --color-words as git-diff (https://www.linuxquestions.org/questions/linux-software-2/setting-git-diff-color-words-as-git-diff-811723/)

potuz 06-02-2010 11:31 AM

setting git-diff --color-words as git-diff
 
Hi there, I like the output of
Code:

git diff --color-words old..new
but I do not know how to set --color-words permanently in the ~/.gitconfig file. Any help would be appreciated.

R.

Edit: I guess I should've said that I do not want an alias for diff --color-words

theNbomr 06-02-2010 12:49 PM

It sounds like you need to use what is known generically as an 'alias'. If you are using bash (or other Korn shell derivative):
Code:

alias git="git diff --color-words"
I'm not familiar with the git command specifically, but I think you should be able to decipher the process. If you want to make this active for all subsequent logins, simply put the command in your ~/.bashrc file.
--- rod.

potuz 06-02-2010 05:08 PM

Luckily my "Edit" was an hour before your post ;)

R.

theNbomr 06-02-2010 06:30 PM

Okay, so now I'm confused about what you do want. Can you spell out the command you presently use, followed separately by the command that you think would be preferable?

--- rod.

potuz 06-02-2010 11:19 PM

Well, I presently use an alias of the form
Code:

git wdiff old..new
where I have an alias as
Code:

[alias]
        wdiff = diff --color-words

Therefore my command is equivalent indeed to
Code:

git diff --color-words old..new
However, I would like to not use an alias (for example because I'd have to change some scripts) and just use
Code:

git diff old..new
and I was hoping that there could be a global variable that I can set on ~/.gitconfig that would add automatically the --color-words clause. Just as is the case if you want to add the --color clause by having color.diff=auto.

I'm sorry for not spelling everything in the original post.

Cheers,

R.

Edit. Just in case someone reads this thread at some point later. If you want to have an alias for a git command, it is much better to put it in your ~/.gitconfig file under the [alias] clause as I posted here instead of a strange alias in bashrc. On the one hand cause it doesn't need to be in memory all time. On the other cause that way you can still use git as the first command. Note that the suggestion in post #2 would've been quite strange when you try "git pull" for example :)

jtriley 09-09-2010 01:31 PM

just found this:

Code:

$ git config --global color.diff auto
or to force always using color:

Code:

$ git config --global color.diff always


All times are GMT -5. The time now is 12:05 PM.