How do I avoid typing “git” at the begining of every Git command?How do I discard unstaged changes in...

Why do I seem to lose data using this bash pipe construction?

Is it true that "only photographers care about noise"?

Why would a home insurer offer a discount based on credit score?

What is this object?

Oil draining out shortly after turbo hose detached/broke

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

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

How to represent jealousy in a cute way?

Entered UK using my now-lost UK passport; can I go to Spain using my US passport?

Problem with pronounciation

What is Gilligan's full Name?

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

If the pressure inside and outside a balloon balance, then why does air leave when it pops?

Is there a better way to do partial sums of array items in JavaScript?

My mom's return ticket is 3 days after I-94 expires

When to use и or а as “and”?

Is all-caps blackletter no longer taboo?

Traceroute showing inter-vlan routing?

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

How to Handle Many Times Series Simultaneously?

What's the best way to quit a job mostly because of money?

Parsing text written the millitext font

Why do (or did, until very recently) aircraft transponders wait to be interrogated before broadcasting beacon signals?

Mathematica 12 has gotten worse at solving simple equations?



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;
}







69















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
    10 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
    9 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
    8 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
    8 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    5 hours ago


















69















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
    10 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
    9 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
    8 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
    8 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    5 hours ago














69












69








69


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 1 hour ago









LogicalBranch

2,0451838




2,0451838










asked 2 days ago









NocturnalNocturnal

376310




376310








  • 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
    10 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
    9 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
    8 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
    8 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    5 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
    10 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
    9 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
    8 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
    8 hours ago






  • 1





    Have you tried TortoiseGit?

    – Vilx-
    5 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
10 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
10 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
9 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
9 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
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
8 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
8 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
8 hours ago




1




1





Have you tried TortoiseGit?

– Vilx-
5 hours ago





Have you tried TortoiseGit?

– Vilx-
5 hours ago












11 Answers
11






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
    6 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
    6 hours ago



















50














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
    19 hours ago








  • 1





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

    – Cedric H.
    14 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
    12 hours ago








  • 2





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

    – Abigail
    8 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
    10 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
    8 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
    7 hours ago











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

    – CoffeeTableEspresso
    2 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














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
    2 hours 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






  • 1





    The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

    – Lie Ryan
    43 mins ago





















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
        7 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
        6 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
        2 hours 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
        2 hours ago












      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

























      11 Answers
      11






      active

      oldest

      votes








      11 Answers
      11






      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
        6 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
        6 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
        6 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
        6 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
        6 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
        6 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
        6 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
        6 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
      6 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
      6 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
      6 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
      6 hours ago













      50














      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
        19 hours ago








      • 1





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

        – Cedric H.
        14 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
        12 hours ago








      • 2





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

        – Abigail
        8 hours ago
















      50














      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
        19 hours ago








      • 1





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

        – Cedric H.
        14 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
        12 hours ago








      • 2





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

        – Abigail
        8 hours ago














      50












      50








      50







      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

      75829




      75829








      • 2





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

        – ruohola
        19 hours ago








      • 1





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

        – Cedric H.
        14 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
        12 hours ago








      • 2





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

        – Abigail
        8 hours ago














      • 2





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

        – ruohola
        19 hours ago








      • 1





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

        – Cedric H.
        14 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
        12 hours ago








      • 2





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

        – Abigail
        8 hours ago








      2




      2





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

      – ruohola
      19 hours ago







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

      – ruohola
      19 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.
      14 hours ago





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

      – Cedric H.
      14 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
      12 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
      12 hours ago






      2




      2





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

      – Abigail
      8 hours ago





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

      – Abigail
      8 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
        10 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
        8 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
        7 hours ago











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

        – CoffeeTableEspresso
        2 hours 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
        10 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
        8 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
        7 hours ago











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

        – CoffeeTableEspresso
        2 hours 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 yesterday









      JacobIRRJacobIRR

      3,89831333




      3,89831333













      • where's commit :P

        – qwr
        10 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
        8 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
        7 hours ago











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

        – CoffeeTableEspresso
        2 hours ago





















      • where's commit :P

        – qwr
        10 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
        8 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
        7 hours ago











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

        – CoffeeTableEspresso
        2 hours ago



















      where's commit :P

      – qwr
      10 hours ago





      where's commit :P

      – qwr
      10 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
      8 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
      8 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
      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
      7 hours ago













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

      – CoffeeTableEspresso
      2 hours ago







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

      – CoffeeTableEspresso
      2 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














      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
        2 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
        2 hours 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
        2 hours 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
        2 hours 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
      2 hours 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
      2 hours 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






      • 1





        The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

        – Lie Ryan
        43 mins 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






      • 1





        The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

        – Lie Ryan
        43 mins ago
















      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






      • 1





        The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

        – Lie Ryan
        43 mins ago





















      • 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






      • 1





        The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

        – Lie Ryan
        43 mins ago



















      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




      1




      1





      The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

      – Lie Ryan
      43 mins ago







      The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.

      – Lie Ryan
      43 mins ago













      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 yesterday









          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 5 hours ago

























                  answered 11 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
                        7 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
                        6 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
                        2 hours 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
                        7 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
                        6 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
                        2 hours 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 9 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
                        7 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
                        6 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
                        2 hours 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
                        7 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
                        6 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
                        2 hours 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
                      7 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
                      7 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
                      6 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
                      6 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
                      2 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
                      2 hours 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
                        2 hours 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
                        2 hours 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 6 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
                        2 hours 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
                        2 hours 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
                      2 hours 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
                      2 hours ago


















                      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

                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                      Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m