0

I've been working on Git, and I did a git commit. I get a load of information about the repository I'm working on, and some error messages about conflicts.

At the bottom of my Git Bash window it says --INSERT-- and I cannot type any more Git commands. When I try to close the window it says "processes are running in session, close anyway?"

As it was unresponsive for a long time with apparently little happening, I gave it a go and closed it.

Now upon reopening, I try to run a git commit again, and I get a slightly different error message. Now at the bottom of my window it says --VISUAL-- and again I can't run any GitHub commands.

How do I resolve this issue and regain control of Git Bash?

enter image description here

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Eoin
  • 1,413
  • 2
  • 17
  • 32
  • 4
    You're not in git, you're in your text editor. This is where it puts you so you can write a commit log message. – Charles Duffy Jun 04 '16 at 19:38
  • 1
    (You're also not in bash, making a "bash" tag inappropriate). – Charles Duffy Jun 04 '16 at 19:39
  • I disagree, I think I am in Git Bash. Isn't the icon top right the bash icon? – Eoin Jun 04 '16 at 19:40
  • Anyways, definitely not related to GitHub. – che Jun 04 '16 at 19:41
  • ...when you run "Git Bash", it starts a terminal. Inside that terminal, it starts bash. When something else is running inside bash, that other thing takes control of the file descriptors to read and write from the terminal. – Charles Duffy Jun 04 '16 at 19:41
  • 1
    ...so, you're at the terminal started for git bash, but the screen you took us a screenshot of isn't from bash, it's from a different piece of software (probably `vim`) started by bash inside that terminal. There's a copy of bash running on your system, but it has nothing to do with anything currently on the terminal's display, and won't take control back until the editor (`vim`) and the git command that started the editor have both exited. – Charles Duffy Jun 04 '16 at 19:42
  • I think I understand... sort of. I start the whole process by right clicking and saying "git bash here". I'm using the same program, but after running a command like git commit I end up in a text editor? Although I don't recognise this because I opened what I incorrectly call Git Bash? – Eoin Jun 04 '16 at 19:43
  • 1
    Right. What you opened is a terminal (rather imprecisely called "Git Bash" in Windows) that was originally running bash, but which subsequently has run git, and then vim, with the commands higher up the stack (`git` and `bash`) sitting around waiting for the editor to exit before they take control of the terminal (which is itself an entirely separate program, not part of bash) back. – Charles Duffy Jun 04 '16 at 19:44
  • Ah, now I understand. Thanks for your patience, and sorry for disagreeing in the first place :) – Eoin Jun 04 '16 at 19:46
  • NP. I've tried to improve the title a bit, so this question is more likely to be found by folks having the same problem. – Charles Duffy Jun 04 '16 at 19:53
  • Thank you. I would argue that my original title might be what a confused noob is thinking, but I wouldn't argue too much. Thanks for your help, I have now managed to commit my [crimes] changes. – Eoin Jun 04 '16 at 19:56
  • 1
    The problem with that style of title is that they're not very specific to a given problem -- you can have 30 or 100 different unrelated problems with the same title, so they don't help people with problems find the question with an answer, or folks with expertise find a question they're interested in helping with. Anyhow, glad I could help. :) – Charles Duffy Jun 04 '16 at 20:09
  • I can see that. Cheers. – Eoin Jun 04 '16 at 20:10
  • 1
    If you want to change this behavior and avoid the text editor completely, you can do this with `git commit -m "enter commit message here"` – Briana Swift Jun 04 '16 at 20:22
  • Thanks, I will be using that in the future – Eoin Jun 04 '16 at 20:24

2 Answers2

4

You're in a text editor -- what looks like vim. Visual mode is used by vim when selecting text, just as insert mode is used when writing text; either can be exited (to command mode) by pressing escape.

Git will often run your configured editor to let you write a commit log message -- in this case, for the merge commit created.

Press the escape key, then :wq to save changes you've made to the file you're in, or :q! to exit without changes.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Ah ha, then I must assume it needs me to edit something. I'll get there. – Eoin Jun 04 '16 at 19:46
  • Yup! That first line `Merge branch 'staging' of https://github.com/joomla/joomla-cms into staging` is its proposed commit message, but it's giving you a chance to write a different one to replace it. (For this specific case, it's perfectly conventional to stick with the default message and just exit the editor without making changes). – Charles Duffy Jun 04 '16 at 19:47
  • Oh I see. So I needn't change it at all then. – Eoin Jun 04 '16 at 19:49
3

What you are looking at in the second screen is your text editor, which in this case has been set to vim.

You can either learn to use vim or change your git text editor: How do I make Git use the editor of my choice for commits?

Community
  • 1
  • 1
Leon
  • 12,013
  • 5
  • 36
  • 59
  • Thanks I've added Sublime Text 2. Much less confusing for a simpleton like me. Nice tip. – Eoin Jun 04 '16 at 19:55