How do I avoid typing “git” at the begining of every Git command?How do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to resolve merge conflicts in GitHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?

Is Jesus the last Prophet?

one-hot-encoding categorical data gives error

How to handle when PCs taste a potion that is actually poison?

A life of PhD: is it feasible?

Grandpa has another non math question

Was planting UN flag on Moon ever discussed?

Forgot passport for Alaska cruise (Anchorage to Vancouver)

How to create a Lightning Web Component without Salesforce DX?

Suppose leased car is totalled: what are financial implications?

In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?

Enchiridion, 16: Does a stoic moan, or not?

Are the guests in Westworld forbidden to tell the hosts that they are robots?

Oil draining out shortly after turbo hose detached/broke

C++ logging library

In American Politics, why is the Justice Department under the President?

What is Gilligan's full Name?

How much web presence should I have?

If absolute velocity does not exist, how can we say a rocket accelerates in empty space?

What plausible reason could I give for my FTL drive only working in space

Traceroute showing inter-vlan routing?

What does this line mean in Zelazny's "The Courts of Chaos"?

Why do Bhargava-Skinner-Zhang consider the ordering by height?

As easy as Three, Two, One... How fast can you go from Five to Four?

Selecting by attribute using Python and a list



How do I avoid typing “git” at the begining of every Git command?


How do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to resolve merge conflicts in GitHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








68















I'm wondering if there's a way to avoid having to type the word git at the beginning of every Git command.



It would be nice if there was a way to use the git command only once in the beginning after opening a command prompt to get into "Git mode".



For example:



git>


After which every command we type is by default interpreted as a Git command.



In a way similar to how we use the MySQL shell to write database commands:



mysql>


This will save me from typing 'git' hundreds of time every day.



NOTE: I'm using git-bash, on Windows.










share|improve this question



















  • 13





    To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

    – JBentley
    9 hours ago






  • 1





    I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

    – LogicalBranch
    8 hours ago












  • You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

    – Lee Daniel Crocker
    7 hours ago







  • 2





    If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

    – chepner
    7 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    4 hours ago

















68















I'm wondering if there's a way to avoid having to type the word git at the beginning of every Git command.



It would be nice if there was a way to use the git command only once in the beginning after opening a command prompt to get into "Git mode".



For example:



git>


After which every command we type is by default interpreted as a Git command.



In a way similar to how we use the MySQL shell to write database commands:



mysql>


This will save me from typing 'git' hundreds of time every day.



NOTE: I'm using git-bash, on Windows.










share|improve this question



















  • 13





    To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

    – JBentley
    9 hours ago






  • 1





    I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

    – LogicalBranch
    8 hours ago












  • You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

    – Lee Daniel Crocker
    7 hours ago







  • 2





    If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

    – chepner
    7 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    4 hours ago













68












68








68


8






I'm wondering if there's a way to avoid having to type the word git at the beginning of every Git command.



It would be nice if there was a way to use the git command only once in the beginning after opening a command prompt to get into "Git mode".



For example:



git>


After which every command we type is by default interpreted as a Git command.



In a way similar to how we use the MySQL shell to write database commands:



mysql>


This will save me from typing 'git' hundreds of time every day.



NOTE: I'm using git-bash, on Windows.










share|improve this question
















I'm wondering if there's a way to avoid having to type the word git at the beginning of every Git command.



It would be nice if there was a way to use the git command only once in the beginning after opening a command prompt to get into "Git mode".



For example:



git>


After which every command we type is by default interpreted as a Git command.



In a way similar to how we use the MySQL shell to write database commands:



mysql>


This will save me from typing 'git' hundreds of time every day.



NOTE: I'm using git-bash, on Windows.







git version-control command-line-interface git-bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 33 mins ago









LogicalBranch

2,0451838




2,0451838










asked 2 days ago









NocturnalNocturnal

371310




371310







  • 13





    To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

    – JBentley
    9 hours ago






  • 1





    I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

    – LogicalBranch
    8 hours ago












  • You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

    – Lee Daniel Crocker
    7 hours ago







  • 2





    If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

    – chepner
    7 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    4 hours ago












  • 13





    To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

    – JBentley
    9 hours ago






  • 1





    I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

    – LogicalBranch
    8 hours ago












  • You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

    – Lee Daniel Crocker
    7 hours ago







  • 2





    If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

    – chepner
    7 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    4 hours ago







13




13





To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

– JBentley
9 hours ago





To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.

– JBentley
9 hours ago




1




1





I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

– LogicalBranch
8 hours ago






I hate to be "that guy" but I've been dealing with this issue for quite a while now so I've created a python script called NoGit to get around this. Given that my answer is at the very bottom (after 9 others) I highly doubt it'll be seen, so I've uploaded the script, it's documentation and other information to a GitHub repository of the same name. Hope it helps.

– LogicalBranch
8 hours ago














You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

– Lee Daniel Crocker
7 hours ago






You could make shell aliases for your most common commands: alias "gc" to "git commit" for example, and alias "gs" to "git status", etc. But frankly, learning to type well will probably serve you better in the long run.

– Lee Daniel Crocker
7 hours ago





2




2





If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

– chepner
7 hours ago





If you are typing git hundreds of times a day, you are either doing little else but running git, or you type fast enough that typing git isn't consuming as much time as you think.

– chepner
7 hours ago




1




1





Have you tried TortoiseGit?

– Vilx-
4 hours ago





Have you tried TortoiseGit?

– Vilx-
4 hours ago












12 Answers
12






active

oldest

votes


















87














You might want to try gitsh. From their readme:




The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.



  • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$



Or have a look at the other projects linked there:





  • git-sh - A customised bash shell with a Git prompt, aliases, and completion.


  • gitsh - A simple Git shell written in Perl.


  • repl - Wraps any program with subcommands in a REPL.



Note: Haven't used this myself.






share|improve this answer




















  • 13





    grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

    – Kevin
    yesterday







  • 3





    @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

    – Yakk - Adam Nevraumont
    5 hours ago






  • 1





    @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

    – Kevin
    5 hours ago


















49














A Perl one-liner which will do this:



perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'


This will execute whatever you type, prefixed with git. And it will keep doing that until you hit ^D.






share|improve this answer


















  • 2





    This really is most similar to what OP is asking for, and in a very lightweight package!

    – ruohola
    18 hours ago







  • 1





    This is probably the best answer and it is very easy to modify it for other, similar, use cases.

    – Cedric H.
    13 hours ago






  • 1





    This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

    – Konrad Rudolph
    11 hours ago







  • 2





    @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

    – Abigail
    7 hours ago


















28














This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc for the Git commands you use most frequently:



alias commit='git commit'
alias checkout='git checkout'
...


Also note that you can create aliases within Git itself:



git config --global alias.ci commit
git config --global alias.co checkout
...


This lets you type git ci instead of git commit, and so on.






share|improve this answer




















  • 3





    The drawback of this approach is that a separate alias would need to be created for every Git command.

    – Tim Biegeleisen
    2 days ago







  • 12





    Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

    – Thomas
    2 days ago






  • 9





    In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

    – rkta
    2 days ago


















13














I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:



# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'





share|improve this answer























  • where's commit :P

    – qwr
    9 hours ago






  • 2





    I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

    – JacobIRR
    7 hours ago












  • Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

    – qwr
    6 hours ago











  • this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

    – CoffeeTableEspresso
    1 hour ago



















12














Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc:



complete -E -W git


Now pressing Tab at an empty Bash prompt will type out "git ".






share|improve this answer


















  • 2





    Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

    – TheOnlyMrCat
    19 hours ago


















12














A friend of mine made a small bash script that accomplishes this. It's called Replify.



$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/

git> remote add origin https://your-url/repo.git

git> checkout -b new-branch
Switched to a new branch 'new-branch'

git> push





share|improve this answer

























  • OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

    – Sergiy Kolodyazhnyy
    1 hour ago


















7














In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:



#include <iostream>
#include <cstdlib>

int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);


return 0;



Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.






share|improve this answer























  • Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

    – Thomas Weller
    yesterday











  • @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

    – john01dav
    yesterday






  • 7





    You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

    – nomadictype
    yesterday











  • @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

    – john01dav
    yesterday


















7














Another approach that will work with any commands: use Ctrl+R (reverse-i-search).



The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.



You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.




  • git commit --amend: <Ctrl+R>am


  • git pull: <Ctrl+R>pu


  • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu


  • git rebase --abort: <Ctrl-R>ab


  • git rebase --continue: <Ctrl-R>con


  • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>up

  • etc

Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.






share|improve this answer






























    3














    I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.



    I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git command, so instead I wrote a python script called NoGit to solve this problem:



    #!/usr/bin/env python
    import sys, os, signal, atexit, readline, subprocess

    commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")

    def run_commands():
    stop = True
    for cmd in commands:
    command = ["git" if not cmd.startswith("git ") else ""]
    command = [cmd] if command[0] == "" else [command[0], cmd]
    subprocess.Popen(command).communicate()
    commands = []

    def signal_handler(sig, frame):
    run_commands()
    sys.exit(0)

    try:
    readline.read_history_file(history_file)
    signal.signal(signal.SIGINT, signal_handler)

    while True:
    if stop == True:
    break
    command = input("git> ")
    if command == "%undo":
    commands.pop()
    elif command == "%run":
    run_commands()
    elif command == "%exit":
    sys.exit(0)
    else:
    commands += [cmd.strip() for cmd in command.split(";")]

    signal.pause()
    readline.set_history_length(-1)
    except IOError:
    pass

    atexit.register(readline.write_history_file, history_file)


    NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.



    Documentation:



    • the %undo command removes the last command from the stack

    • the %run command runs the commands in the stack and clears the stack

    • the %exit command closes the CLI without doing anything

    • pressing ctr+c is the same as running %run; %exit

    • the script saves commands that were executed to a file called git.history in the same folder as the script

    • you can add multiple commands in one line using a semi-colon

    • you can use the keyword git in the beginning of the command and the script won't duplicate it (E.G: git init doesn't become git git init)

    Example commands:



    1. init

    2. add .

    3. stage .

    4. commit -m "inital commit"

    5. %run; %exit

    Additional information (for Linux users):



    If you want you can remove the .py extension and convert it into an executable using:



    mv ./git.py ./git
    chmod +x ./git


    Then instead of calling the script like this:



    python3 git.py


    You'd run this instead:



    ./git


    Additional information (for lazy people):



    If you're lazy and don't want to type out a ./ then you could move this script to your /bin/ folder and create an alias for it.



    If you're really, really lazy, use the following commands:



    sudo cp ./git /bin/nogit
    sudo chmod +x /bin/nogit
    alias nogit='/bin/nogit'


    If you're really, really, really lazy, copy and paste the following one-liner:



    sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'


    If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:



    sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'


    Good luck.






    share|improve this answer
































      2














      Use your editor.



      Type the command like commit from your favorite editor like vs code and be more efficient with git:



      enter image description here



      Or type git to get all the commands:



      enter image description here






      share|improve this answer




















      • 7





        I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

        – Glen Pierce
        7 hours ago






      • 2





        I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

        – LogicalBranch
        6 hours ago












      • Thanks @GlenPierce your feedback is just very precious.

        – prosti
        6 hours ago






      • 3





        @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

        – prosti
        5 hours ago











      • I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

        – CoffeeTableEspresso
        1 hour ago


















      0














      For basic stuff, you can do:



      function ggit() while true; do; printf 'git> '; read; eval git $REPLY; done 


      git> status
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      Changes not staged for commit:
      (use "git add/rm <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

      deleted: yarn.lock

      no changes added to commit (use "git add" and/or "git commit -a")
      git> add .
      git> status
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)

      deleted: yarn.lock

      git>


      Exit with ctrl+c






      share|improve this answer























      • Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

        – Sergiy Kolodyazhnyy
        1 hour ago


















      0














      Look up aliases for your operating system or a 3rd party software like gitsh






      share|improve this answer








      New contributor



      Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56505000%2fhow-do-i-avoid-typing-git-at-the-begining-of-every-git-command%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        12 Answers
        12






        active

        oldest

        votes








        12 Answers
        12






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        87














        You might want to try gitsh. From their readme:




        The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.



        • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

        sh$ gitsh
        gitsh% status
        gitsh% add .
        gitsh% commit -m "Ship it!"
        gitsh% push
        gitsh% ctrl-d
        sh$



        Or have a look at the other projects linked there:





        • git-sh - A customised bash shell with a Git prompt, aliases, and completion.


        • gitsh - A simple Git shell written in Perl.


        • repl - Wraps any program with subcommands in a REPL.



        Note: Haven't used this myself.






        share|improve this answer




















        • 13





          grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

          – Kevin
          yesterday







        • 3





          @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

          – Yakk - Adam Nevraumont
          5 hours ago






        • 1





          @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

          – Kevin
          5 hours ago















        87














        You might want to try gitsh. From their readme:




        The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.



        • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

        sh$ gitsh
        gitsh% status
        gitsh% add .
        gitsh% commit -m "Ship it!"
        gitsh% push
        gitsh% ctrl-d
        sh$



        Or have a look at the other projects linked there:





        • git-sh - A customised bash shell with a Git prompt, aliases, and completion.


        • gitsh - A simple Git shell written in Perl.


        • repl - Wraps any program with subcommands in a REPL.



        Note: Haven't used this myself.






        share|improve this answer




















        • 13





          grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

          – Kevin
          yesterday







        • 3





          @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

          – Yakk - Adam Nevraumont
          5 hours ago






        • 1





          @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

          – Kevin
          5 hours ago













        87












        87








        87







        You might want to try gitsh. From their readme:




        The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.



        • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

        sh$ gitsh
        gitsh% status
        gitsh% add .
        gitsh% commit -m "Ship it!"
        gitsh% push
        gitsh% ctrl-d
        sh$



        Or have a look at the other projects linked there:





        • git-sh - A customised bash shell with a Git prompt, aliases, and completion.


        • gitsh - A simple Git shell written in Perl.


        • repl - Wraps any program with subcommands in a REPL.



        Note: Haven't used this myself.






        share|improve this answer















        You might want to try gitsh. From their readme:




        The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.



        • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

        sh$ gitsh
        gitsh% status
        gitsh% add .
        gitsh% commit -m "Ship it!"
        gitsh% push
        gitsh% ctrl-d
        sh$



        Or have a look at the other projects linked there:





        • git-sh - A customised bash shell with a Git prompt, aliases, and completion.


        • gitsh - A simple Git shell written in Perl.


        • repl - Wraps any program with subcommands in a REPL.



        Note: Haven't used this myself.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        alfunxalfunx

        1,718618




        1,718618







        • 13





          grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

          – Kevin
          yesterday







        • 3





          @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

          – Yakk - Adam Nevraumont
          5 hours ago






        • 1





          @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

          – Kevin
          5 hours ago












        • 13





          grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

          – Kevin
          yesterday







        • 3





          @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

          – Yakk - Adam Nevraumont
          5 hours ago






        • 1





          @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

          – Kevin
          5 hours ago







        13




        13





        grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

        – Kevin
        yesterday






        grumble... repl(1) is not a REPL. It doesn't eval or print anything. It runs programs.

        – Kevin
        yesterday





        3




        3





        @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

        – Yakk - Adam Nevraumont
        5 hours ago





        @Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.

        – Yakk - Adam Nevraumont
        5 hours ago




        1




        1





        @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

        – Kevin
        5 hours ago





        @Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the fork()/exec()), so repl(1) isn't even doing that.

        – Kevin
        5 hours ago













        49














        A Perl one-liner which will do this:



        perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'


        This will execute whatever you type, prefixed with git. And it will keep doing that until you hit ^D.






        share|improve this answer


















        • 2





          This really is most similar to what OP is asking for, and in a very lightweight package!

          – ruohola
          18 hours ago







        • 1





          This is probably the best answer and it is very easy to modify it for other, similar, use cases.

          – Cedric H.
          13 hours ago






        • 1





          This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

          – Konrad Rudolph
          11 hours ago







        • 2





          @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

          – Abigail
          7 hours ago















        49














        A Perl one-liner which will do this:



        perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'


        This will execute whatever you type, prefixed with git. And it will keep doing that until you hit ^D.






        share|improve this answer


















        • 2





          This really is most similar to what OP is asking for, and in a very lightweight package!

          – ruohola
          18 hours ago







        • 1





          This is probably the best answer and it is very easy to modify it for other, similar, use cases.

          – Cedric H.
          13 hours ago






        • 1





          This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

          – Konrad Rudolph
          11 hours ago







        • 2





          @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

          – Abigail
          7 hours ago













        49












        49








        49







        A Perl one-liner which will do this:



        perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'


        This will execute whatever you type, prefixed with git. And it will keep doing that until you hit ^D.






        share|improve this answer













        A Perl one-liner which will do this:



        perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'


        This will execute whatever you type, prefixed with git. And it will keep doing that until you hit ^D.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        AbigailAbigail

        74829




        74829







        • 2





          This really is most similar to what OP is asking for, and in a very lightweight package!

          – ruohola
          18 hours ago







        • 1





          This is probably the best answer and it is very easy to modify it for other, similar, use cases.

          – Cedric H.
          13 hours ago






        • 1





          This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

          – Konrad Rudolph
          11 hours ago







        • 2





          @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

          – Abigail
          7 hours ago












        • 2





          This really is most similar to what OP is asking for, and in a very lightweight package!

          – ruohola
          18 hours ago







        • 1





          This is probably the best answer and it is very easy to modify it for other, similar, use cases.

          – Cedric H.
          13 hours ago






        • 1





          This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

          – Konrad Rudolph
          11 hours ago







        • 2





          @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

          – Abigail
          7 hours ago







        2




        2





        This really is most similar to what OP is asking for, and in a very lightweight package!

        – ruohola
        18 hours ago






        This really is most similar to what OP is asking for, and in a very lightweight package!

        – ruohola
        18 hours ago





        1




        1





        This is probably the best answer and it is very easy to modify it for other, similar, use cases.

        – Cedric H.
        13 hours ago





        This is probably the best answer and it is very easy to modify it for other, similar, use cases.

        – Cedric H.
        13 hours ago




        1




        1





        This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

        – Konrad Rudolph
        11 hours ago






        This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s -ne flags).

        – Konrad Rudolph
        11 hours ago





        2




        2





        @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

        – Abigail
        7 hours ago





        @KonradRudolph perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'

        – Abigail
        7 hours ago











        28














        This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc for the Git commands you use most frequently:



        alias commit='git commit'
        alias checkout='git checkout'
        ...


        Also note that you can create aliases within Git itself:



        git config --global alias.ci commit
        git config --global alias.co checkout
        ...


        This lets you type git ci instead of git commit, and so on.






        share|improve this answer




















        • 3





          The drawback of this approach is that a separate alias would need to be created for every Git command.

          – Tim Biegeleisen
          2 days ago







        • 12





          Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

          – Thomas
          2 days ago






        • 9





          In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

          – rkta
          2 days ago















        28














        This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc for the Git commands you use most frequently:



        alias commit='git commit'
        alias checkout='git checkout'
        ...


        Also note that you can create aliases within Git itself:



        git config --global alias.ci commit
        git config --global alias.co checkout
        ...


        This lets you type git ci instead of git commit, and so on.






        share|improve this answer




















        • 3





          The drawback of this approach is that a separate alias would need to be created for every Git command.

          – Tim Biegeleisen
          2 days ago







        • 12





          Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

          – Thomas
          2 days ago






        • 9





          In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

          – rkta
          2 days ago













        28












        28








        28







        This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc for the Git commands you use most frequently:



        alias commit='git commit'
        alias checkout='git checkout'
        ...


        Also note that you can create aliases within Git itself:



        git config --global alias.ci commit
        git config --global alias.co checkout
        ...


        This lets you type git ci instead of git commit, and so on.






        share|improve this answer















        This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc for the Git commands you use most frequently:



        alias commit='git commit'
        alias checkout='git checkout'
        ...


        Also note that you can create aliases within Git itself:



        git config --global alias.ci commit
        git config --global alias.co checkout
        ...


        This lets you type git ci instead of git commit, and so on.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited yesterday

























        answered 2 days ago









        ThomasThomas

        117k35257369




        117k35257369







        • 3





          The drawback of this approach is that a separate alias would need to be created for every Git command.

          – Tim Biegeleisen
          2 days ago







        • 12





          Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

          – Thomas
          2 days ago






        • 9





          In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

          – rkta
          2 days ago












        • 3





          The drawback of this approach is that a separate alias would need to be created for every Git command.

          – Tim Biegeleisen
          2 days ago







        • 12





          Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

          – Thomas
          2 days ago






        • 9





          In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

          – rkta
          2 days ago







        3




        3





        The drawback of this approach is that a separate alias would need to be created for every Git command.

        – Tim Biegeleisen
        2 days ago






        The drawback of this approach is that a separate alias would need to be created for every Git command.

        – Tim Biegeleisen
        2 days ago





        12




        12





        Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

        – Thomas
        2 days ago





        Only for the most frequently used. I mean, how often do you use git hash-object or git interpret-trailers? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.

        – Thomas
        2 days ago




        9




        9





        In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

        – rkta
        2 days ago





        In addition to ci for commit I also use a shell alias g for git, this reduces most of the typing and lets me stay in my preferred shell.

        – rkta
        2 days ago











        13














        I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:



        # git
        alias gw='git whatchanged'
        alias gg='git grep -n -C8'
        alias ggi='git grep -i -n -C8'
        alias gb='git branch'
        alias gbd='git branch -D'
        alias gba='git branch -a'
        alias gc='git checkout'
        alias gcp='git cherry-pick'
        alias gfo='git fetch origin'
        alias s='git status'
        alias gmom='git merge origin/master'
        alias grom='git rebase origin/master'
        alias gpom='git pull origin master'
        alias pplog='git log --oneline --graph --decorate'





        share|improve this answer























        • where's commit :P

          – qwr
          9 hours ago






        • 2





          I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

          – JacobIRR
          7 hours ago












        • Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

          – qwr
          6 hours ago











        • this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

          – CoffeeTableEspresso
          1 hour ago
















        13














        I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:



        # git
        alias gw='git whatchanged'
        alias gg='git grep -n -C8'
        alias ggi='git grep -i -n -C8'
        alias gb='git branch'
        alias gbd='git branch -D'
        alias gba='git branch -a'
        alias gc='git checkout'
        alias gcp='git cherry-pick'
        alias gfo='git fetch origin'
        alias s='git status'
        alias gmom='git merge origin/master'
        alias grom='git rebase origin/master'
        alias gpom='git pull origin master'
        alias pplog='git log --oneline --graph --decorate'





        share|improve this answer























        • where's commit :P

          – qwr
          9 hours ago






        • 2





          I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

          – JacobIRR
          7 hours ago












        • Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

          – qwr
          6 hours ago











        • this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

          – CoffeeTableEspresso
          1 hour ago














        13












        13








        13







        I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:



        # git
        alias gw='git whatchanged'
        alias gg='git grep -n -C8'
        alias ggi='git grep -i -n -C8'
        alias gb='git branch'
        alias gbd='git branch -D'
        alias gba='git branch -a'
        alias gc='git checkout'
        alias gcp='git cherry-pick'
        alias gfo='git fetch origin'
        alias s='git status'
        alias gmom='git merge origin/master'
        alias grom='git rebase origin/master'
        alias gpom='git pull origin master'
        alias pplog='git log --oneline --graph --decorate'





        share|improve this answer













        I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:



        # git
        alias gw='git whatchanged'
        alias gg='git grep -n -C8'
        alias ggi='git grep -i -n -C8'
        alias gb='git branch'
        alias gbd='git branch -D'
        alias gba='git branch -a'
        alias gc='git checkout'
        alias gcp='git cherry-pick'
        alias gfo='git fetch origin'
        alias s='git status'
        alias gmom='git merge origin/master'
        alias grom='git rebase origin/master'
        alias gpom='git pull origin master'
        alias pplog='git log --oneline --graph --decorate'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 23 hours ago









        JacobIRRJacobIRR

        3,89831333




        3,89831333












        • where's commit :P

          – qwr
          9 hours ago






        • 2





          I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

          – JacobIRR
          7 hours ago












        • Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

          – qwr
          6 hours ago











        • this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

          – CoffeeTableEspresso
          1 hour ago


















        • where's commit :P

          – qwr
          9 hours ago






        • 2





          I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

          – JacobIRR
          7 hours ago












        • Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

          – qwr
          6 hours ago











        • this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

          – CoffeeTableEspresso
          1 hour ago

















        where's commit :P

        – qwr
        9 hours ago





        where's commit :P

        – qwr
        9 hours ago




        2




        2





        I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

        – JacobIRR
        7 hours ago






        I don't include commit or push since I want a few extra seconds (while typing) to be sure that I'm not destroying something

        – JacobIRR
        7 hours ago














        Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

        – qwr
        6 hours ago





        Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.

        – qwr
        6 hours ago













        this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

        – CoffeeTableEspresso
        1 hour ago






        this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned

        – CoffeeTableEspresso
        1 hour ago












        12














        Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc:



        complete -E -W git


        Now pressing Tab at an empty Bash prompt will type out "git ".






        share|improve this answer


















        • 2





          Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

          – TheOnlyMrCat
          19 hours ago















        12














        Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc:



        complete -E -W git


        Now pressing Tab at an empty Bash prompt will type out "git ".






        share|improve this answer


















        • 2





          Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

          – TheOnlyMrCat
          19 hours ago













        12












        12








        12







        Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc:



        complete -E -W git


        Now pressing Tab at an empty Bash prompt will type out "git ".






        share|improve this answer













        Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc:



        complete -E -W git


        Now pressing Tab at an empty Bash prompt will type out "git ".







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        nomadictypenomadictype

        490210




        490210







        • 2





          Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

          – TheOnlyMrCat
          19 hours ago












        • 2





          Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

          – TheOnlyMrCat
          19 hours ago







        2




        2





        Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

        – TheOnlyMrCat
        19 hours ago





        Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in ~/zshrc, for tcsh, you'll put it in ~/tcshrc, etc.

        – TheOnlyMrCat
        19 hours ago











        12














        A friend of mine made a small bash script that accomplishes this. It's called Replify.



        $ replify git
        Initialized REPL for [git]
        git> init
        Initialized empty Git repository in /your/directory/here/.git/

        git> remote add origin https://your-url/repo.git

        git> checkout -b new-branch
        Switched to a new branch 'new-branch'

        git> push





        share|improve this answer

























        • OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

          – Sergiy Kolodyazhnyy
          1 hour ago















        12














        A friend of mine made a small bash script that accomplishes this. It's called Replify.



        $ replify git
        Initialized REPL for [git]
        git> init
        Initialized empty Git repository in /your/directory/here/.git/

        git> remote add origin https://your-url/repo.git

        git> checkout -b new-branch
        Switched to a new branch 'new-branch'

        git> push





        share|improve this answer

























        • OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

          – Sergiy Kolodyazhnyy
          1 hour ago













        12












        12








        12







        A friend of mine made a small bash script that accomplishes this. It's called Replify.



        $ replify git
        Initialized REPL for [git]
        git> init
        Initialized empty Git repository in /your/directory/here/.git/

        git> remote add origin https://your-url/repo.git

        git> checkout -b new-branch
        Switched to a new branch 'new-branch'

        git> push





        share|improve this answer















        A friend of mine made a small bash script that accomplishes this. It's called Replify.



        $ replify git
        Initialized REPL for [git]
        git> init
        Initialized empty Git repository in /your/directory/here/.git/

        git> remote add origin https://your-url/repo.git

        git> checkout -b new-branch
        Switched to a new branch 'new-branch'

        git> push






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 11 hours ago









        wjandrea

        2,1531333




        2,1531333










        answered 18 hours ago









        Sam WeaverSam Weaver

        494617




        494617












        • OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

          – Sergiy Kolodyazhnyy
          1 hour ago

















        • OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

          – Sergiy Kolodyazhnyy
          1 hour ago
















        OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

        – Sergiy Kolodyazhnyy
        1 hour ago





        OK, I've already mentioned that on Umur's answer, but the use of eval in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done instead

        – Sergiy Kolodyazhnyy
        1 hour ago











        7














        In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:



        #include <iostream>
        #include <cstdlib>

        int main(int argc, char *argv[])
        while(true)
        std::cout << "git> ";
        std::cout.flush();
        std::string command;
        std::getline(std::cin, command);
        if(command == "exit") break;
        std::system("git " + command);


        return 0;



        Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.






        share|improve this answer























        • Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

          – Thomas Weller
          yesterday











        • @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

          – john01dav
          yesterday






        • 7





          You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

          – nomadictype
          yesterday











        • @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

          – john01dav
          yesterday















        7














        In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:



        #include <iostream>
        #include <cstdlib>

        int main(int argc, char *argv[])
        while(true)
        std::cout << "git> ";
        std::cout.flush();
        std::string command;
        std::getline(std::cin, command);
        if(command == "exit") break;
        std::system("git " + command);


        return 0;



        Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.






        share|improve this answer























        • Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

          – Thomas Weller
          yesterday











        • @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

          – john01dav
          yesterday






        • 7





          You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

          – nomadictype
          yesterday











        • @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

          – john01dav
          yesterday













        7












        7








        7







        In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:



        #include <iostream>
        #include <cstdlib>

        int main(int argc, char *argv[])
        while(true)
        std::cout << "git> ";
        std::cout.flush();
        std::string command;
        std::getline(std::cin, command);
        if(command == "exit") break;
        std::system("git " + command);


        return 0;



        Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.






        share|improve this answer













        In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:



        #include <iostream>
        #include <cstdlib>

        int main(int argc, char *argv[])
        while(true)
        std::cout << "git> ";
        std::cout.flush();
        std::string command;
        std::getline(std::cin, command);
        if(command == "exit") break;
        std::system("git " + command);


        return 0;



        Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        john01davjohn01dav

        779420




        779420












        • Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

          – Thomas Weller
          yesterday











        • @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

          – john01dav
          yesterday






        • 7





          You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

          – nomadictype
          yesterday











        • @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

          – john01dav
          yesterday

















        • Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

          – Thomas Weller
          yesterday











        • @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

          – john01dav
          yesterday






        • 7





          You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

          – nomadictype
          yesterday











        • @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

          – john01dav
          yesterday
















        Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

        – Thomas Weller
        yesterday





        Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.

        – Thomas Weller
        yesterday













        @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

        – john01dav
        yesterday





        @ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.

        – john01dav
        yesterday




        7




        7





        You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

        – nomadictype
        yesterday





        You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?

        – nomadictype
        yesterday













        @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

        – john01dav
        yesterday





        @nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).

        – john01dav
        yesterday











        7














        Another approach that will work with any commands: use Ctrl+R (reverse-i-search).



        The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.



        You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.




        • git commit --amend: <Ctrl+R>am


        • git pull: <Ctrl+R>pu


        • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu


        • git rebase --abort: <Ctrl-R>ab


        • git rebase --continue: <Ctrl-R>con


        • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>up

        • etc

        Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.






        share|improve this answer



























          7














          Another approach that will work with any commands: use Ctrl+R (reverse-i-search).



          The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.



          You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.




          • git commit --amend: <Ctrl+R>am


          • git pull: <Ctrl+R>pu


          • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu


          • git rebase --abort: <Ctrl-R>ab


          • git rebase --continue: <Ctrl-R>con


          • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>up

          • etc

          Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.






          share|improve this answer

























            7












            7








            7







            Another approach that will work with any commands: use Ctrl+R (reverse-i-search).



            The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.



            You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.




            • git commit --amend: <Ctrl+R>am


            • git pull: <Ctrl+R>pu


            • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu


            • git rebase --abort: <Ctrl-R>ab


            • git rebase --continue: <Ctrl-R>con


            • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>up

            • etc

            Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.






            share|improve this answer













            Another approach that will work with any commands: use Ctrl+R (reverse-i-search).



            The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.



            You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.




            • git commit --amend: <Ctrl+R>am


            • git pull: <Ctrl+R>pu


            • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu


            • git rebase --abort: <Ctrl-R>ab


            • git rebase --continue: <Ctrl-R>con


            • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>up

            • etc

            Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 23 hours ago









            Lie RyanLie Ryan

            46.6k1075125




            46.6k1075125





















                3














                I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.



                I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git command, so instead I wrote a python script called NoGit to solve this problem:



                #!/usr/bin/env python
                import sys, os, signal, atexit, readline, subprocess

                commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")

                def run_commands():
                stop = True
                for cmd in commands:
                command = ["git" if not cmd.startswith("git ") else ""]
                command = [cmd] if command[0] == "" else [command[0], cmd]
                subprocess.Popen(command).communicate()
                commands = []

                def signal_handler(sig, frame):
                run_commands()
                sys.exit(0)

                try:
                readline.read_history_file(history_file)
                signal.signal(signal.SIGINT, signal_handler)

                while True:
                if stop == True:
                break
                command = input("git> ")
                if command == "%undo":
                commands.pop()
                elif command == "%run":
                run_commands()
                elif command == "%exit":
                sys.exit(0)
                else:
                commands += [cmd.strip() for cmd in command.split(";")]

                signal.pause()
                readline.set_history_length(-1)
                except IOError:
                pass

                atexit.register(readline.write_history_file, history_file)


                NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.



                Documentation:



                • the %undo command removes the last command from the stack

                • the %run command runs the commands in the stack and clears the stack

                • the %exit command closes the CLI without doing anything

                • pressing ctr+c is the same as running %run; %exit

                • the script saves commands that were executed to a file called git.history in the same folder as the script

                • you can add multiple commands in one line using a semi-colon

                • you can use the keyword git in the beginning of the command and the script won't duplicate it (E.G: git init doesn't become git git init)

                Example commands:



                1. init

                2. add .

                3. stage .

                4. commit -m "inital commit"

                5. %run; %exit

                Additional information (for Linux users):



                If you want you can remove the .py extension and convert it into an executable using:



                mv ./git.py ./git
                chmod +x ./git


                Then instead of calling the script like this:



                python3 git.py


                You'd run this instead:



                ./git


                Additional information (for lazy people):



                If you're lazy and don't want to type out a ./ then you could move this script to your /bin/ folder and create an alias for it.



                If you're really, really lazy, use the following commands:



                sudo cp ./git /bin/nogit
                sudo chmod +x /bin/nogit
                alias nogit='/bin/nogit'


                If you're really, really, really lazy, copy and paste the following one-liner:



                sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'


                If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:



                sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'


                Good luck.






                share|improve this answer





























                  3














                  I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.



                  I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git command, so instead I wrote a python script called NoGit to solve this problem:



                  #!/usr/bin/env python
                  import sys, os, signal, atexit, readline, subprocess

                  commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")

                  def run_commands():
                  stop = True
                  for cmd in commands:
                  command = ["git" if not cmd.startswith("git ") else ""]
                  command = [cmd] if command[0] == "" else [command[0], cmd]
                  subprocess.Popen(command).communicate()
                  commands = []

                  def signal_handler(sig, frame):
                  run_commands()
                  sys.exit(0)

                  try:
                  readline.read_history_file(history_file)
                  signal.signal(signal.SIGINT, signal_handler)

                  while True:
                  if stop == True:
                  break
                  command = input("git> ")
                  if command == "%undo":
                  commands.pop()
                  elif command == "%run":
                  run_commands()
                  elif command == "%exit":
                  sys.exit(0)
                  else:
                  commands += [cmd.strip() for cmd in command.split(";")]

                  signal.pause()
                  readline.set_history_length(-1)
                  except IOError:
                  pass

                  atexit.register(readline.write_history_file, history_file)


                  NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.



                  Documentation:



                  • the %undo command removes the last command from the stack

                  • the %run command runs the commands in the stack and clears the stack

                  • the %exit command closes the CLI without doing anything

                  • pressing ctr+c is the same as running %run; %exit

                  • the script saves commands that were executed to a file called git.history in the same folder as the script

                  • you can add multiple commands in one line using a semi-colon

                  • you can use the keyword git in the beginning of the command and the script won't duplicate it (E.G: git init doesn't become git git init)

                  Example commands:



                  1. init

                  2. add .

                  3. stage .

                  4. commit -m "inital commit"

                  5. %run; %exit

                  Additional information (for Linux users):



                  If you want you can remove the .py extension and convert it into an executable using:



                  mv ./git.py ./git
                  chmod +x ./git


                  Then instead of calling the script like this:



                  python3 git.py


                  You'd run this instead:



                  ./git


                  Additional information (for lazy people):



                  If you're lazy and don't want to type out a ./ then you could move this script to your /bin/ folder and create an alias for it.



                  If you're really, really lazy, use the following commands:



                  sudo cp ./git /bin/nogit
                  sudo chmod +x /bin/nogit
                  alias nogit='/bin/nogit'


                  If you're really, really, really lazy, copy and paste the following one-liner:



                  sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'


                  If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:



                  sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'


                  Good luck.






                  share|improve this answer



























                    3












                    3








                    3







                    I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.



                    I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git command, so instead I wrote a python script called NoGit to solve this problem:



                    #!/usr/bin/env python
                    import sys, os, signal, atexit, readline, subprocess

                    commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")

                    def run_commands():
                    stop = True
                    for cmd in commands:
                    command = ["git" if not cmd.startswith("git ") else ""]
                    command = [cmd] if command[0] == "" else [command[0], cmd]
                    subprocess.Popen(command).communicate()
                    commands = []

                    def signal_handler(sig, frame):
                    run_commands()
                    sys.exit(0)

                    try:
                    readline.read_history_file(history_file)
                    signal.signal(signal.SIGINT, signal_handler)

                    while True:
                    if stop == True:
                    break
                    command = input("git> ")
                    if command == "%undo":
                    commands.pop()
                    elif command == "%run":
                    run_commands()
                    elif command == "%exit":
                    sys.exit(0)
                    else:
                    commands += [cmd.strip() for cmd in command.split(";")]

                    signal.pause()
                    readline.set_history_length(-1)
                    except IOError:
                    pass

                    atexit.register(readline.write_history_file, history_file)


                    NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.



                    Documentation:



                    • the %undo command removes the last command from the stack

                    • the %run command runs the commands in the stack and clears the stack

                    • the %exit command closes the CLI without doing anything

                    • pressing ctr+c is the same as running %run; %exit

                    • the script saves commands that were executed to a file called git.history in the same folder as the script

                    • you can add multiple commands in one line using a semi-colon

                    • you can use the keyword git in the beginning of the command and the script won't duplicate it (E.G: git init doesn't become git git init)

                    Example commands:



                    1. init

                    2. add .

                    3. stage .

                    4. commit -m "inital commit"

                    5. %run; %exit

                    Additional information (for Linux users):



                    If you want you can remove the .py extension and convert it into an executable using:



                    mv ./git.py ./git
                    chmod +x ./git


                    Then instead of calling the script like this:



                    python3 git.py


                    You'd run this instead:



                    ./git


                    Additional information (for lazy people):



                    If you're lazy and don't want to type out a ./ then you could move this script to your /bin/ folder and create an alias for it.



                    If you're really, really lazy, use the following commands:



                    sudo cp ./git /bin/nogit
                    sudo chmod +x /bin/nogit
                    alias nogit='/bin/nogit'


                    If you're really, really, really lazy, copy and paste the following one-liner:



                    sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'


                    If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:



                    sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'


                    Good luck.






                    share|improve this answer















                    I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.



                    I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git command, so instead I wrote a python script called NoGit to solve this problem:



                    #!/usr/bin/env python
                    import sys, os, signal, atexit, readline, subprocess

                    commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")

                    def run_commands():
                    stop = True
                    for cmd in commands:
                    command = ["git" if not cmd.startswith("git ") else ""]
                    command = [cmd] if command[0] == "" else [command[0], cmd]
                    subprocess.Popen(command).communicate()
                    commands = []

                    def signal_handler(sig, frame):
                    run_commands()
                    sys.exit(0)

                    try:
                    readline.read_history_file(history_file)
                    signal.signal(signal.SIGINT, signal_handler)

                    while True:
                    if stop == True:
                    break
                    command = input("git> ")
                    if command == "%undo":
                    commands.pop()
                    elif command == "%run":
                    run_commands()
                    elif command == "%exit":
                    sys.exit(0)
                    else:
                    commands += [cmd.strip() for cmd in command.split(";")]

                    signal.pause()
                    readline.set_history_length(-1)
                    except IOError:
                    pass

                    atexit.register(readline.write_history_file, history_file)


                    NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.



                    Documentation:



                    • the %undo command removes the last command from the stack

                    • the %run command runs the commands in the stack and clears the stack

                    • the %exit command closes the CLI without doing anything

                    • pressing ctr+c is the same as running %run; %exit

                    • the script saves commands that were executed to a file called git.history in the same folder as the script

                    • you can add multiple commands in one line using a semi-colon

                    • you can use the keyword git in the beginning of the command and the script won't duplicate it (E.G: git init doesn't become git git init)

                    Example commands:



                    1. init

                    2. add .

                    3. stage .

                    4. commit -m "inital commit"

                    5. %run; %exit

                    Additional information (for Linux users):



                    If you want you can remove the .py extension and convert it into an executable using:



                    mv ./git.py ./git
                    chmod +x ./git


                    Then instead of calling the script like this:



                    python3 git.py


                    You'd run this instead:



                    ./git


                    Additional information (for lazy people):



                    If you're lazy and don't want to type out a ./ then you could move this script to your /bin/ folder and create an alias for it.



                    If you're really, really lazy, use the following commands:



                    sudo cp ./git /bin/nogit
                    sudo chmod +x /bin/nogit
                    alias nogit='/bin/nogit'


                    If you're really, really, really lazy, copy and paste the following one-liner:



                    sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'


                    If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:



                    sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'


                    Good luck.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 4 hours ago

























                    answered 10 hours ago









                    LogicalBranchLogicalBranch

                    2,0451838




                    2,0451838





















                        2














                        Use your editor.



                        Type the command like commit from your favorite editor like vs code and be more efficient with git:



                        enter image description here



                        Or type git to get all the commands:



                        enter image description here






                        share|improve this answer




















                        • 7





                          I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                          – Glen Pierce
                          7 hours ago






                        • 2





                          I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                          – LogicalBranch
                          6 hours ago












                        • Thanks @GlenPierce your feedback is just very precious.

                          – prosti
                          6 hours ago






                        • 3





                          @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                          – prosti
                          5 hours ago











                        • I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                          – CoffeeTableEspresso
                          1 hour ago















                        2














                        Use your editor.



                        Type the command like commit from your favorite editor like vs code and be more efficient with git:



                        enter image description here



                        Or type git to get all the commands:



                        enter image description here






                        share|improve this answer




















                        • 7





                          I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                          – Glen Pierce
                          7 hours ago






                        • 2





                          I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                          – LogicalBranch
                          6 hours ago












                        • Thanks @GlenPierce your feedback is just very precious.

                          – prosti
                          6 hours ago






                        • 3





                          @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                          – prosti
                          5 hours ago











                        • I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                          – CoffeeTableEspresso
                          1 hour ago













                        2












                        2








                        2







                        Use your editor.



                        Type the command like commit from your favorite editor like vs code and be more efficient with git:



                        enter image description here



                        Or type git to get all the commands:



                        enter image description here






                        share|improve this answer















                        Use your editor.



                        Type the command like commit from your favorite editor like vs code and be more efficient with git:



                        enter image description here



                        Or type git to get all the commands:



                        enter image description here







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 8 hours ago

























                        answered 9 hours ago









                        prostiprosti

                        7,90513241




                        7,90513241







                        • 7





                          I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                          – Glen Pierce
                          7 hours ago






                        • 2





                          I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                          – LogicalBranch
                          6 hours ago












                        • Thanks @GlenPierce your feedback is just very precious.

                          – prosti
                          6 hours ago






                        • 3





                          @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                          – prosti
                          5 hours ago











                        • I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                          – CoffeeTableEspresso
                          1 hour ago












                        • 7





                          I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                          – Glen Pierce
                          7 hours ago






                        • 2





                          I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                          – LogicalBranch
                          6 hours ago












                        • Thanks @GlenPierce your feedback is just very precious.

                          – prosti
                          6 hours ago






                        • 3





                          @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                          – prosti
                          5 hours ago











                        • I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                          – CoffeeTableEspresso
                          1 hour ago







                        7




                        7





                        I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                        – Glen Pierce
                        7 hours ago





                        I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.

                        – Glen Pierce
                        7 hours ago




                        2




                        2





                        I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                        – LogicalBranch
                        6 hours ago






                        I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.

                        – LogicalBranch
                        6 hours ago














                        Thanks @GlenPierce your feedback is just very precious.

                        – prosti
                        6 hours ago





                        Thanks @GlenPierce your feedback is just very precious.

                        – prosti
                        6 hours ago




                        3




                        3





                        @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                        – prosti
                        5 hours ago





                        @LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.

                        – prosti
                        5 hours ago













                        I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                        – CoffeeTableEspresso
                        1 hour ago





                        I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.

                        – CoffeeTableEspresso
                        1 hour ago











                        0














                        For basic stuff, you can do:



                        function ggit() while true; do; printf 'git> '; read; eval git $REPLY; done 


                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes not staged for commit:
                        (use "git add/rm <file>..." to update what will be committed)
                        (use "git checkout -- <file>..." to discard changes in working directory)

                        deleted: yarn.lock

                        no changes added to commit (use "git add" and/or "git commit -a")
                        git> add .
                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes to be committed:
                        (use "git reset HEAD <file>..." to unstage)

                        deleted: yarn.lock

                        git>


                        Exit with ctrl+c






                        share|improve this answer























                        • Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                          – Sergiy Kolodyazhnyy
                          1 hour ago















                        0














                        For basic stuff, you can do:



                        function ggit() while true; do; printf 'git> '; read; eval git $REPLY; done 


                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes not staged for commit:
                        (use "git add/rm <file>..." to update what will be committed)
                        (use "git checkout -- <file>..." to discard changes in working directory)

                        deleted: yarn.lock

                        no changes added to commit (use "git add" and/or "git commit -a")
                        git> add .
                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes to be committed:
                        (use "git reset HEAD <file>..." to unstage)

                        deleted: yarn.lock

                        git>


                        Exit with ctrl+c






                        share|improve this answer























                        • Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                          – Sergiy Kolodyazhnyy
                          1 hour ago













                        0












                        0








                        0







                        For basic stuff, you can do:



                        function ggit() while true; do; printf 'git> '; read; eval git $REPLY; done 


                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes not staged for commit:
                        (use "git add/rm <file>..." to update what will be committed)
                        (use "git checkout -- <file>..." to discard changes in working directory)

                        deleted: yarn.lock

                        no changes added to commit (use "git add" and/or "git commit -a")
                        git> add .
                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes to be committed:
                        (use "git reset HEAD <file>..." to unstage)

                        deleted: yarn.lock

                        git>


                        Exit with ctrl+c






                        share|improve this answer













                        For basic stuff, you can do:



                        function ggit() while true; do; printf 'git> '; read; eval git $REPLY; done 


                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes not staged for commit:
                        (use "git add/rm <file>..." to update what will be committed)
                        (use "git checkout -- <file>..." to discard changes in working directory)

                        deleted: yarn.lock

                        no changes added to commit (use "git add" and/or "git commit -a")
                        git> add .
                        git> status
                        On branch master
                        Your branch is ahead of 'origin/master' by 1 commit.
                        (use "git push" to publish your local commits)

                        Changes to be committed:
                        (use "git reset HEAD <file>..." to unstage)

                        deleted: yarn.lock

                        git>


                        Exit with ctrl+c







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 5 hours ago









                        Umur KontacıUmur Kontacı

                        33.2k56390




                        33.2k56390












                        • Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                          – Sergiy Kolodyazhnyy
                          1 hour ago

















                        • Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                          – Sergiy Kolodyazhnyy
                          1 hour ago
















                        Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                        – Sergiy Kolodyazhnyy
                        1 hour ago





                        Decent idea, however there's two problems. One, the ; after do leads to bash: syntax error near unexpected token ;'` Second, the eval part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better

                        – Sergiy Kolodyazhnyy
                        1 hour ago











                        0














                        Look up aliases for your operating system or a 3rd party software like gitsh






                        share|improve this answer








                        New contributor



                        Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0














                          Look up aliases for your operating system or a 3rd party software like gitsh






                          share|improve this answer








                          New contributor



                          Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





















                            0












                            0








                            0







                            Look up aliases for your operating system or a 3rd party software like gitsh






                            share|improve this answer








                            New contributor



                            Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            Look up aliases for your operating system or a 3rd party software like gitsh







                            share|improve this answer








                            New contributor



                            Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.








                            share|improve this answer



                            share|improve this answer






                            New contributor



                            Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.








                            answered 1 hour ago









                            Luis SuarezLuis Suarez

                            11




                            11




                            New contributor



                            Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.




                            New contributor




                            Luis Suarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56505000%2fhow-do-i-avoid-typing-git-at-the-begining-of-every-git-command%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367