top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Redirect "git" subcommand to itself?

+1 vote

I just run into this problem again (which happens to me maybe twice a week):

I want to do a git operations, so I type "git " into my shell, and then I look around what exactly I want to do and usually I find it in the help text of a previous command such as

 You are currently reverting commit 383c14b.
 (fix conflicts and run "git revert --continue")
 (use "git revert --abort" to cancel the revert operation)

then I copy the whole operation "git revert --abort" in this case and paste it to the shell and let go. The result looks like

 $ git git revert --abort
 git: 'git' is not a git command. See 'git --help'.

 Did you mean this?

I wonder if we want to make a "git" subcommand, which behaves exactly the same as git itself?
Then "git git git status" would just return the same as "git status".

posted May 28, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

A few unrelated thoughts.

  • Perhaps we should omit 'git' from these advice-texts? E.g.

    use "revert --abort" to cancel

    I dunno.

  • While we bend over backwards to a certain degree to be helpful, I somehow feel making "git git" a synonym to "git" is going too far, akin to asking POSIX maintainers to define "act", "cta", "atc", "tca", and "tac" all as synonyms to "cat" because you often fat-finger when typing "cat" (yes, "tac" does something else that is more useful, I know).

  • You can help yourself with something like this, I suppose:

    git = "!sh -c 'exec git "$@"' -"

    but I personally feel that it is too ugly to live as part of our official suggestion, so please do not send a patch to add it as a built-in alias ;-).

answer May 28, 2015 by Alok Sharma
Similar Questions
0 votes

I have a problem with an already committed file into my repo. This git repo was converted from svn to git some years ago. Last week I have change some lines in a file and I saw in the diff that it is marked as binary (it's a simple .cpp file). I think on the first commit it was detected as an utf-16 file (on windows). But no matter what I do I can't get it back to a "normal text" text file (git does not detect that), but I is now only utf-8. I also replace the whole content of the file with just 'a' and git say it's binary.

Is the only way to get it back to text-mode?:
* copy a utf-8 version of the original file
* delete the file
* make a commit
* add the old file as a new one

I think that will work but it will also break my history.

Is there a better way to get these behavior without losing history?

0 votes

I work on some files and push/merge them to the remote server. Sometimes I get merge conflicts on those files and have to fix them. That's completely fine. I get that.

What I don't understand is that sometimes during this process I will get merge conflicts in files _I have never touched_. In fact they are in a completely different series of directories to the one I am working on and someone else project entirely. How am I meant to know how to fix these? I dont know what the other developer wanted to do and if they have done it right.

I thought git only merged/pushed the files you have changed? If someone else has changed Group A files on the remote repo, why must I change my local Group A files when I am _pushing _completely different set of Group B files?

Sure, Id understand if I were pulling files down to my local and had to resolve merge conflicts then, but this isn't happening when I push the files up.

Any help or advice is much appreciated. Sorry if I sound frustrated - I am really trying hard to get my head round this whole git thing but its just so weird.

0 votes

I have a local repository and a remote at GitHub. My local repo had a master branch and the remote had only a gh-pages branch.

I wanted to pull from my gh-pages remote branch (with "git pull origin gh-pages"). I was about to commit on the master branch and I realized I had no local gh-pages branch. So I put a blank message, to avoid commiting to the master branch.

I unstaged the changes with "git reset HEAD", but how can I remove the already fetched files. I mean, is there something I have to do after unstaging the fetched files?

Many thanks for your help,