2

I would like to add my own flag to an existing git command. Is this doable?

Something like git diff --myownthing.

How would I do this?

000
  • 26,951
  • 10
  • 71
  • 101
  • 2
    Echo "hooray it worked" and exit. What does it matter? – 000 Mar 06 '14 at 23:05
  • 1
    because I'm curious of the practical usage. What exact process will "echo hooray"? `git` is the command to process arguments, how is it supposed to pass the execution to something else? – zerkms Mar 06 '14 at 23:12
  • When I `git pull --rebase` and a conflict occurs, it says "fix yer crap and hit `git pull --continue`, or `--abort`.". I want to create another option `--table` which will not abort the procedure, but let me leave all this crap in an unfinished state and pick it up later. I *could* create a new `git table` command but I feel that it's part of `pull`, not it's own standalone command. – 000 Mar 06 '14 at 23:21
  • Watch out for the word "table." It means different things in different locales: http://en.wikipedia.org/wiki/Table_%28parliamentary_procedure%29 (to "table" something in the US means to put it aside for now; in most of the rest of the world it means the opposite, i.e. to bring something into consideration). – Gary Fixler Mar 06 '14 at 23:24
  • @Joe Frambach: so you want to change the `git` command behaviour not just simply "add a custom flag". For that you obviously need to download `git` sources, patch it, compile and use. – zerkms Mar 06 '14 at 23:30
  • Ok that answers my question. It is not obvious thank you very much. – 000 Mar 06 '14 at 23:39
  • Maybe we can finally have **git merge -s theirs** ... – Brain2000 May 29 '19 at 20:22

3 Answers3

1

In your .gitconfig file you can define bash functions as aliases. I'm not sure if you could get the functionality you want but you could make git pull perform some other steps as well as /instead of the default.

For instance I have diff = "!f() { git diff --color=always "$@" | less -R; }; f" as an alias which pipes git diff to less rather than stdout.

Holloway
  • 6,412
  • 1
  • 26
  • 33
0

I'm not sure if you can modify the built-in Git commands to accept additional parameters without actually modifying Git source code, but you can easily make Git aliases that will accept parameters.

See, for example:

  1. https://stackoverflow.com/a/3322412/456814
  2. https://stackoverflow.com/a/7005698/456814
Community
  • 1
  • 1