FAQ: Basic Git Workflow - git init

This community-built FAQ covers the “git init” exercise from the lesson “Basic Git Workflow”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development
Computer Science

Learn Git

FAQs on the exercise git init

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

In this lesson, are we creating a local or remote project/repository? Perhaps a short concepts intro would help setup lesson expectations.

1 Like

Is this “bash” terminal only for Linux? Would I be typing this stuff into the Command Prompt on Windows?

You can (I have) install Bash on Windows. There are a few commands that work for both Command Prompt and Bash Terminal. See this link: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Step_by_Step_Guide/ap-doslinux.html

In step 1, I added a string to some text file. In step 2 I typed git init at a bash prompt and it created a project directory under sorcerers code. Where and how did it know where to create it? (sorcerers-code) Was there some information I wasn’t aware of in Step 1 that told me where the .txt file was?

1 Like

I came on here to ask the same. Anyone?

1 Like

If you run the command directly it will try to create a repository in the current working directory which is, or should be, the /home/ccuser/workspace/sorcerers-code directory (you can check working directory with pwd). So roughly equivalent to git init . (the . links to current dir); you could use a path as an argument if you want to e.g. git init ~/path/to/project.

The repo will offer to track items within this directory recursively, one of which is the relevant .txt file.

1 Like

Got the exercise right git init sorcerers-code, got the message to say it is right but the next button does nto allow continue.

It feels like being thrown right into it. Some initial context would be helpful.

Is Git already pre installed on my mac?
Can I just write that code in bash and that works?
How do I define the location of the repository?

Thanks for the help.