Git Getting Started

Divya Srinivasan

Getting Started with Git

Now that you’ve installed Git and configured your identity, you’re ready to start using it.
Let’s walk through creating your first repository.

Key Steps to Get Started

  • Create a project folder
Make a new folder for your project files.
  • Navigate to the folder
Open your terminal or Git Bash and move into your new folder.
  • Initialize a Git repository
Turn the folder into a Git repository by running
git init

Create a Project Folder

Let’s start by setting up a new folder for your project:

Example:

mkdir myproject
cd myproject
  • mkdir creates a new directory named myproject.
  • cd moves us into that directory.

Initialize Git

Now that you’re inside your project folder, you can initialize a Git repository there:

Example

git init
This will create an empty Git repository:
Initialized empty Git repository in /Users/user/myproject/.git/
Congratulations — you’ve just created your first Git repository!

What is a Repository?

A Git repository is simply a folder that Git monitors for changes.
It keeps track of your project’s entire history, including all previous versions of your files.

What Happens When You Run git init?

When you run git init, Git sets up version control in your project by creating a hidden folder named .git.
This .git folder holds everything Git needs to track your project’s files, changes, and history.

Example: 

View the Hidden .git Folder (Linux/macOS)
ls -a
.  ..  .git
On Windows, you may need to enable “Show hidden files” in File Explorer to see the .git folder.

Troubleshooting

Error: git: command not found
Fix: Ensure that Git is properly installed on your system and that it’s included in your system’s PATH. If you’ve just installed it, try restarting your terminal.

Error: Permission denied
Fix: on Windows, run your terminal as an administrator. On macOS or Linux, try using sudo to gain the necessary permissions.








Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send