Weird terminal behavior with "git difftool" - terminal

When I try to use "git difftool", the terminal seems to enter a mode where hitting the "enter" key outputs ^M instead of accepting the default option:
$ git difftool --tool=tkdiff file
Viewing (1/1): 'file'
Launch 'tkdiff' [Y/n]: ^M^M^M^M^M^M^M^M
I can control-c out of it, but I can't get difftool to work.
"git diff" works like a charm.
I am struggling to Google for this problem.
I am running Ubuntu 14.04.2 LTS, my TERM is xterm, and my .gitconfig is very simple, it has nothing about output in it:
[user]
name = My Name
email = myemail#example.com
[alias]
co = checkout
How can I use "git difftool"?

Probably a terminal configuration problem rather than a git issue. Run stty sane to see if that helps or follow other instructions in this similar post: https://askubuntu.com/questions/441744/pressing-enter-produces-m-instead-of-a-newline

Related

How do I enter the commit message in this bash pop-up?

I want to merge a remote repository to a new repository on GitHub. I have tried the following bash commands:
git init
git commit --allow-empty -m "Initial dummy commit"
git remote add --fetch old_a <OldA repo URL>
git merge old_a/master --allow-unrelated-histories
After executing the last command, this screen pops up:
Here bash is asking me to enter a commit message. But typing appears to be prohibited everywhere except in the yellow line. Not only that, I can't even terminate this prompt if I want to go back to the command line. There seems no way to break out other than closing bash itself. So how do I proceed from here?
PS: I have already tried to change my default git editor to vim using the following commands:
git config --global core.editor vim
As well as,
export EDITOR="vim"
But both of these commands didn't work.
This is not an issue, all you need to do is
Press Insert Key and then Enter Key. This will allow you to type a message
Once you have done that Press Esace (Esc) then :wq to exit

Git colors don't display in Windows command prompt

I assume that it's because of the color setting in my config file, but I've tried changing that to no avail. Maybe I'm not doing that right?
Notice that Git Bash shows branch color in green, but on window cl it's not showing at all!
$ git branch
* add_bower *<~~~ only the asterisk appears on the windows prompt.*
master
git in cmd should work just fine. I would check both your gitconfig local and gitconfig global before giving up here.
the first thing I would do is a
git branch --color
or
git diff --color
you can also use the -c option
git -c color.ui=always status
if you see colors then what is likely happening is your local gitconfig is overriding the setting in your global gitconfig
at that point do a
git config --local --edit
if things say auto or true and you still don't see colors. set the output to always. I recommend this b\c it is possible for git to make mistakes and not treat cmd as a terminal
from git-config:
If this is set to always, git-diff(1), git-log(1), and git-show(1)
will use color for all patches. If it is set to true or auto, those
commands will only use color when output is to the terminal. Defaults
to false.
like so
[color]
branch = always
diff = always
interactive = always
status = always
ui = always
hope this helps!
I don't think the command prompt will support coloring different parts of the output out of the box. You'd probably need some extension or add-on to handle it. Have you considered using Powershell? In addition to the built-in support for the coloring you're looking for, it's also much more versatile and powerful than the normal command prompt.
I'm seeing the exact same problem, only for some command prompts. (By default it works, but when I run my team's "razzle" customization script the output is broken like your screenshot. Oddly, coloring in git log and status works fine; just branch is broken.)
I created a new shortcut that launched the same customization script, and the output is fixed for my new shortcut. Very weird.
If you run git branch --no-color you see the right output, just without color?
You can run git config --local --add color.branch never to set that as the default for this repo.

How does one disable Git's HTML help (on Windows)?

I installed Github for Windows which comes with the Git command line client, and whenever I forget a switch or something and want to use --help, instead of dumping to the console it's launching a browser. Is there a way to ask Git to dump the help to the console (as it does in most Unixen by default) instead of launching a browser?
In windows
git <command> -h
will write help to the terminal output
git <command> --help
will pop up a browser window
This is a frail workaround, but if you just want a quick usage summary, feed the git sub-command of your choice a deliberately bad option name. I tried "--halp". For example:
$ git stash --halp
error: unknown option for 'stash save': --halp
To provide a message, use git stash save -- '--halp'
usage: git core\git-stash list [<options>]
or: git core\git-stash show [<stash>]
or: git core\git-stash drop [-q|--quiet] [<stash>]
or: git core\git-stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
or: git core\git-stash branch <branchname> [<stash>]
or: git core\git-stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
[-u|--include-untracked] [-a|--all] [<message>]]
or: git core\git-stash clear
I can't say for sure that "halp" will always be rejected, but it seems to get the job done. Hopefully it'll never get interpreted as a usable parameter. This is probably better than random typing, for example, since you might randomly type in correct input.
For Linux systems you could set this with git config --global help.format <web|man|info>. Unfortunately the man pages are not part of the Git for Windows bundle so only 'web' works.

Why is "git grep" behaving erratic on my Windows PC?

I'm using Github and Git bash on my Windows PC (running XP).
On Ubuuntu I'm happyily using git grep to plough through my code, but every time I call something like:
git grep "some text in my repo"
on Windows I get the results and afterwards I'm stuck with the bash window showing all kind of things [END], ~, [RETURN]... whenever I try to enter something.
Question:
What else besides CTRL+R, CTRL+Q, FN+END, Q, ESC can I try to not having to force-close and reopen git:bash in order to continue to work.
Thanks!
EDIT:
This is what I mean:
As soon as I start typing, the [END] string re-appears (or 50 lines ~) and I cannot write any command on Git, because whatever is in the way swallows half of what I'm typing.... nice description...
I was wondering about this also after installing git and running git bash. It seems "git grep" pipes commands through "less".
Solution: Just type q.
Is git launching less (or something similar) so up/down arrows on your keyboard scrolls through the matches? If you don't want that, try the instructions from https://stackoverflow.com/a/12166923/972216:
set GIT_PAGER=cat
Would disable it for your console session once, or
git config --global core.pager cat
to disable it for your account.

gitbash (cache passphrase key): Can't get the ssh-agent to run on windows, modified the .bashrc & .profile

can anyone help, i am on windows and git is working with my origin set to github.
Of course everytime i wish to pull / push or anything i need to supply the passphrase of the key for github.
According to what i have read i need to edit either a ~/.profile or ~/.bashrc and enter some text
see https://help.github.com/articles/working-with-ssh-key-passphrases
I have done this many times, i actually entered it in both files but when i open up a new GitBash windows nothing seems to run (i assume something is suppose to run and ask my for my passphrase according to the link above).
So of course every Push or Pull again asks me for the passphrase every single time.
I am obviosly missing something here can anyone help?
Remembering that i am on windows :-) and using gitbash that ships with git for windows.
Thanks in advance
Well after a lot of investigation, i found this Remember Password, Git bash under windows
which explains exactly what is needed, its different from linux it appears.
This might happen in case You've cloned the repository through the "https" method and now trying to do push/pull the "ssh" way or other way round.
See if this would work out for you :
git remote set-url origin git#github.com:your_account/your_repo.git
On Windows 10 this worked for me
run git bash
touch ~/.profile
start ~/.profile to open .profile
add the following to .profile
#! /bin/bash
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
This is based on this answer. The only difference is that .bashrc did not work, instead .profile worked.

Resources