Git and the terminal

Hi there,
I’m trying to delve deeper into git by playing with it on dummy repositories. However, I’m a newbie in using the terminal, and at times I don’t understand if it’s my lack of experience with it or with git that blocks me.
For example, today, I was trying the git rebase -i command, but I couldn’t understand how to format and use the message on the terminal:

Screen Shot 2021-08-03 at 12.22.29

Basically, I don’t know what I need to know; can someone point me in the right direction (git docs? terminal docs?) ? I’m on mac.

Thank you

Have you looked up tutorials on git rebase? I use interactive rebase all the time, and ultimately I learned from Googling examples of how that syntax works.

Yes, I have.
It’s not the syntax that I don’t understand, it’s the ‘how to’.
So far I’ve discovered that to modify a line I need to press ‘a’, and then I can modify say, ‘pick’ into ‘drop’. But after that, how do I ‘fire’ the rebase action?
I’m sure I’m missing something trivial, probably something about how the terminal works…

Once you have modified the file, you save and exit and the rebase should happen automatically. How you save and exit depends upon the text editor you have as your default.

1 Like

Hi @Marco16168 , welcome to the wonders of Vim: one of the oldest text editor, yet one of the most loved (and feared) one.

Why did vim open?
With git, certain command will require the usage of a text editor to modify certain elements. It just happens that vim is the default for many.

You don’t need to become a master in it, but you need to know a couple of commands to perform the bare minimum.

I suggest you to type vimtutor in your terminal, and follow the brief introduction.

Have fun exploring the “mouseless” editor. :slight_smile:

Edit: forgot to mention that you can of course change the default editor that git opens with:

$ git config --global core.editor [editor]

1 Like

All right, thanks. That was what I was missing I guess.

Thank you! I will.

This is brilliant :joy: :joy: :joy: , I can totally relate

I would suggest configuring git to use the editor you use for coding.

For example VS Code: git config --global core.editor "code --wait"

2 Likes

There are a few situations like this one where Git will launch a default text editor. As @lasjorg pointed out, it’s worth figuring out how to make it use an editor that you like.

At some point, it’s a good idea to at least learn the bare basics of Vim because you’re likely to run into it from time to time, but if it’s blocking you from getting comfortable with Git, then just put it on a list for later.

2 Likes

Well, at least know :wq if nothing else.

I never took the time to really learn VIM so that is about as much as I know, how to GT*O.

1 Like

Insert, save and quit is pretty much all I remember when I haven’t had to use Vim heavily in a while. But if I’m on a strange computer and Git opens Vim, those are the only commands I need anyway. :woman_shrugging:

1 Like

Thank you @JeremyLT and @ArielLeslie.
What tricked me was that I didn’t realize that I was actually on Vim, hence my complete cluelessness.

1 Like

Hi Marco,
You can also refer to a great resource called Pro Git by [Scott Chacon & Ben Straub ]. Their book coverers Git fairly extensively. You can find it at Pro Git Book.

I hope it guides you as well as it has done for me.

1 Like

Thank you @RedRagon,
it looks like a more approachable, yet comprehensive alternative to the official reference.
Happy coding!

You are welcome. I’m busy deep-diving into DVCS, specifically Git, Mercurial and one or two others that may be worthwhile learning. I find many interesting articles and references out there. So, if you need anything specific, let me know and I’ll pass on the related information I have on it.

1 Like

Thanks, I will.
That’s very kind of you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.