0

I am learning Git via the Pro Git book.
To begin setup it tells to open Terminal and execute git init on the project I want to start revisioning.

Problem is: this command successfully creates a .git hidden folder only if I execute it in my home directory (\Users\<username>).

If I drag the needed folder into Terminal and write git init I get the error: is a directory.
What does that mean?
I have read plenty of guides and no one seems to help me.

How do I setup Git via Terminal in a successful way? The linked questions' instructions didn't help.

NotationMaster
  • 390
  • 3
  • 17

1 Answers1

3

git init create a project in that folder you're in. So create a new folder first and change in that folder.

mkdir test
cd test
git init

You can find it in the documentation in the last example:

https://git-scm.com/docs/git-init

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • Thank you! Forgive my ignorance but I am a very beginner to Git and to Command Line. You say 'the folder you are in' ... do you mean 'in Finder' or should I let Terminal know I am in that directory? – NotationMaster Apr 21 '18 at 22:14
  • 3
    In Terminal ;) perhaps you should learn the linux commands first or use a GUI Git client. – René Höhle Apr 21 '18 at 22:15
  • I tried the `cd` followed by the directory path but I do not see any progress on it. Is it correct to do that? Should I hit Return before adding `git init` or not? – NotationMaster Apr 21 '18 at 22:18
  • Thank you! By the way ... epic fail ... in the end even if the Terminal throws me the 'is a directory' error it still created a .git folder in E V E R Y single project of the folder ... about a 100 of them :-) – NotationMaster Apr 21 '18 at 22:27
  • 1
    That doesn’t sound normal. Definitely remove the .git folder inside your home directory. – evolutionxbox Apr 21 '18 at 22:37
  • I have done that and now it seems I have made some progress. Changed the directory of focus in Terminal to the desired one, run `git init`successfully on it, run the `git add .` successfully on it and now also the `git commit` but it seems now it is stuck. I mean ... it tells me _please enter the commit message for your changes_ and then there is a list of files as this is the initial commit. What should I write and where? – NotationMaster Apr 21 '18 at 22:41
  • 1
    @NeeratheWildMage: Git opens your favorite editor. How does Git know *which* editor is your favorite? (There are multiple answers, not enough room in the comment here to go into detail.) You need to use this editor to write your commit message, so that `git commit` can go on to make the commit with that message. It's a lot of stuff to learn at once! – torek Apr 21 '18 at 23:47
  • @Stony do you know of a good resource for learning the command line? For macOS possibly! Thank you! – NotationMaster Apr 22 '18 at 08:41
  • @torek actually, writing `git commit -lm ` worked :) ... I then set up the —global editor to Atom so that it opens that when I want to edit! Thank you for your help! – NotationMaster Apr 22 '18 at 08:45