tags:

views:

152

answers:

2

I want to know if there is a way to set a flag by default for git command. Specifically, I want to set the --abbrev-commit flag so that when executing git log, I want to execute git log --abbrev-commit.

Unlike the question "is there any way to set a flag by default for a git command?", there is apparently not a configuration flag for adding --abbrev-commit to git log. Furthermore, the git manual states that I cannot create an alias: "To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored"

My third option is to invent a new alias like glog=log --abbrev-commit in my .gitconfig file. But I'd rather not invent my own DSL with new commands.

Is there another way to achieve it so that the abbrev-commit flag is set by default??

+1  A: 

Every utility we use (svn, maven, git, ...) are always encapsulated in a .bat (on Windows, or .sh on Unix), in order to offer our developers one directory to add to their path.

If git is encapsulated in a wrapper script, then... everything is possible.

But that remains a solution linked to the user's setup, not linked to Git itself or the git repo.

VonC
So you mean i should be able to achieve it by adding alias to my .bash_profile?
Jesper Rønn-Jensen
@Jesper: that is the idea, since your wrapper git.bat will be able to detect what Git command you want to execute and could add any option it wants.
VonC
+1  A: 

You can use git aliases: https://git.wiki.kernel.org/index.php/Aliases

git config alias.lg "log --oneline"

Then you can run git lg

hasen j
I want to avoid creating my own syntax so I'd prefer a solution where I don't use `git lg` but `git log`
Jesper Rønn-Jensen
why? what difference would it make?
hasen j
The very important difference is that I don't want to introduce "Jespers git syntax" on my system. I want me (and others using my machine) to use the generic commands. Also, this will make my work faster on other machines: I don't worry about accidentally typing "git lg" and getting a "not found" error
Jesper Rønn-Jensen