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?

7
  • 2
    Echo "hooray it worked" and exit. What does it matter? Commented Mar 6, 2014 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? Commented Mar 6, 2014 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. Commented Mar 6, 2014 at 23:21
  • Watch out for the word "table." It means different things in different locales: 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). Commented Mar 6, 2014 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. Commented Mar 6, 2014 at 23:30

3 Answers 3

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.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.